开发者

WebView does not launch with a normal URL

My WebView does not launch with a normal URL

I have don开发者_开发知识库e everything I could, The browser is simply not launching... I have tried attaching webclient too, doesnt works. I have the internet permission in the manifest. Could anyOne help me here? :(

Its so simple and its not workin.

void somemethod()
   {
  WebView myWebView = new WebView(mycontext);
  myWebView.loadUrl("http://stackoverflow.com/questions/5066778/android-html-image-prob");
   }        


This is not the code to launch a browser bro. This is the code to open url into the embedded webview inside the app.

To open the url in Android's default browser try this

Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(strURL));

startActivity(myIntent);

To open a url into the embedded browser, embed a webview in a layout and then call the second line in your code.


If you really want to use WebView instead of Browser intent, there is two way. One way is to declare a webview in layout file, connect it to Activity class and set some attributes and load the url.

Other way is to declare the WebView dynamically. In that case you have to set necessary attributes, set layout parameters and you must add it to content view. Then load the url.

Here is a tutorial Hello, WebView

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜