开发者

Android URL redirect in webview [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

android webview click opens default browser

I have an application that opens a website in webview on start, however I can't seem to figure out how to keep any URL's that a user clicked on from opening in the browser.

Is there anyway to load the clicked URL inside the webview app?

EDIT - Using the below solution I still get an error on the private class "Illegal modifier for the local class MainScreenActivity; only abstract or final is permitted"... even if I try to rename this I get the same error

public class MainScreenActivity extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle icicle) {

    super.onCreate(icicle);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    WebView webview = new WebView(this);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.loadUrl("http://www.talk-of-the-tyne.co.uk");
    setCont开发者_开发技巧entView(webview);

    private class MainScreenActivity extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }
    }
}

Apologies if I am being thick about this, I just can't seem to get my head around this one


try this code:

WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebViewClient(new WebViewClient());
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜