0

How do I make WebView to open link in WebView itself instead of browser?

Here's my code:

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dsaif); runDialog(5); WebView engine = (WebView) findViewById(R.id.web_engine); engine.loadUrl("http://android.dsaif.tk/store/"); } 

Please give full code with fixes as I'm very new to Android Development. Thanks.

3 Answers 3

5

try like this...

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dsaif); runDialog(5); WebView engine = (WebView) findViewById(R.id.web_engine); engine.loadUrl("http://android.dsaif.tk/store/"); engine.setWebViewClient( new HelloWebViewClient() ); } private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading( WebView view, String url ) { return false; } } 
Sign up to request clarification or add additional context in comments.

Comments

0

Try this piece of code.........

 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.share_email); webE = (WebView)viewToLoad.findViewById(R.id.webE); webE.loadUrl("http://some url"); webE.setWebViewClient(new HelloWebViewClient()); } class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } 

Comments

0

We faced this problem in our project too. And we solved it by using jQuery Mobile in web side of project. Then i can suggest you to use jQuery Mobile if you are coding the webside of your project .

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.