开发者

Problem in using WebView?

I hav开发者_开发知识库e created a page which has link to a page of a website. So for showing that on I have used a WebView and it works fine.

My Problem is that when I click on any link given on that webpage, the link opens in phone's default browser view. But I want all the links to be opened in my created WebView.

Have I made any mistake or it is right..

Please Help Me My code is as follows...

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        Log.e("------------", ".........................................................................................");
        setContentView(R.layout.terms_of_use_web_view_page);

        btn_back = (Button) findViewById(R.id.terms_of_use_button_back);
        btn_back.setOnClickListener(this); 
        webview = (WebView)findViewById(R.id.terms_of_use_webview);
        webview.getSettings().setJavaScriptEnabled(false);
        webview.loadUrl("http://www.oomphlink.com/terms-of-use/");


    }


Try specifying your own WebViewClient:

WebView webView = (WebView)findViewById( R.id.terms_of_use_webview );
webView.setWebViewClient( new WebViewClient() 
{
    @Override
    public boolean shouldOverrideUrlLoading( WebView view, String url )
    {
        view.loadUrl( url );
        return true;
    }
});

To further understand why this is necessary have a look at the documentation for the shouldOverrideUrlLoading method.


wv.setWebViewClient(new MyWebViewClient());

public class MyWebViewClient extends WebViewClient{
}

link for more info...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜