Sabiha Taskin
Sabiha Taskin

Reputation: 113

TextView + WebView

enter image description hereI am using TextView as of yet to display both text and URL, but I want an architecture where I can use both TextView as well as Webview. WebView will be visible-gone and only Enable it when "https//" appears in my TextView. How do I go about it? Please help

Upvotes: 1

Views: 648

Answers (2)

Sabiha Taskin
Sabiha Taskin

Reputation: 113

String url = output.getText().toString();
    if ( url.contains("http://") )
    {
        Toast.makeText(getApplicationContext(),"Hello URL",Toast.LENGTH_SHORT).show();
        web.setVisibility(View.VISIBLE);
        web.getSettings().setJavaScriptEnabled(true);
        web.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        web.loadUrl(url);

    }else
    { web.setVisibility(View.GONE);
    }

I solved using the above code. Thanks all for the help.

Upvotes: 0

Mohammad Ahsan
Mohammad Ahsan

Reputation: 60

You can check dynamically if the string in your TextView contains the substring "https". An easy way to do this would be something like this:

String s = myTextView.getText().toString();
if s.contains("https"){
    //Do something
}

Upvotes: 2

Related Questions