Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open WebView link to new activity?

How do I open link in webpage to new activity (what contains WebView aswell)?

I have webpage where is list and every list item contain different link. So I want that when user press first item it opens second activity and load that link to second activity's WebView. Hope you understand what I try to ask :)

Is that possible?

like image 486
Eljas Avatar asked Feb 22 '12 01:02

Eljas


1 Answers

You can override the URL link clicks and open an activity on each click:

    webView = new WebView(this);
    webView.setWebViewClient(new WebViewClient()
        {
            // Override URL
            public boolean shouldOverrideUrlLoading(WebView view, String url)
            {
                Intent intent = new Intent(...);
                startActivity(intent);
                return true;
            }
        });
like image 162
triad Avatar answered Oct 29 '22 01:10

triad