Need Help Changing From Stock Android Browser To Webview
Ok, so I've got my app done, and I'm working on minor tweaks for it, and one thing is I would prefer my web links to launch in webview instead of the stock browser... I've tried so
Solution 1:
You need to extend WebViewClient, and launch the url within that.
publicclassWebActivityextendsActivity
{
@OverridepublicvoidonCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
webview = (WebView) findViewById(R.id.wv);
webview.setWebViewClient(newWebC());
webview.loadUrl(baseUrl);
}
publicclassWebCextendsWebViewClient
{
@OverridepublicvoidonReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
super.onReceivedError(view, errorCode, description, failingUrl);
}
@OverridepublicbooleanshouldOverrideUrlLoading(WebView view, String url)
{
... etc.
And in your layout xml,
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"><WebViewandroid:id="@+id/wv"android:layout_width="fill_parent"android:layout_height="fill_parent"/></LinearLayout>
Post a Comment for "Need Help Changing From Stock Android Browser To Webview"