Issue
I need a page which show web contents in a fixed width
and height
.
I put a webview inside a xml file with a height of 200px,but while loading that page,it directly redirect to default browser view.
While press the back button in the phone,it redirect to the original page,then the webview shows nothing.
in my xml file
<WebView android:layout_width="fill_parent" android:layout_height="200px" android:id="@+id/wvbrowser" />
in code
WebView wvbrowser;
wvbrowser=(WebView)findViewById(R.id.wvbrowser);
wvbrowser.loadUrl("http://www.orkut.com");
So tell me where I am Wrong? and how to show WebView in FIXED size?
Solution
Try this...
create a separate class.
public class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
Then in your activity use this.
WebView wvbrowser;
wvbrowser=(WebView)findViewById(R.id.wvbrowser);
wvbrowser.setWebViewClient(new HelloWebViewClient());
wvbrowser.getSettings().setJavaScriptEnabled(true);
wvbrowser.loadUrl("http://www.orkut.com");
Answered By - Noby
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.