How Add A Webview To A Layout That Have More Widgets
I want to add a webview to my layout.But that layout have few other widgets also.But when i run the application webview takes the entire screen and other widgets get disappear.here
Solution 1:
Try to set the WebViewClient, it will solve your problem.
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView wv1=(WebView)findViewById(R.id.web1);
wv1.setWebViewClient(new myClient());
wv1.loadUrl("http://google.com");
}
class myClient extends WebViewClient
{
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url);
return true;
}
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// TODO Auto-generated method stub
super.onReceivedError(view, errorCode, description, failingUrl);
}
}
Solution 2:
change your xml like this, then your textview vill be shown on the botton, the view will be shown above the textview, the webview will be shown in the rest spase.
<RelativeLayout
...
>
<TextView
android:layout_alignParentBottom="true"
android:id="@+id/sample_text"
...
/>
<View
android:layout_above="@id/sample_text"
android:id="@+id/sample_view"
...
>
<WebView
android:layout_above="@id/sample_view"
...
/>
</RelativeLayout>
Post a Comment for "How Add A Webview To A Layout That Have More Widgets"