Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android How to Display Links in webview like this?

Does anyone know of a way to Display URL's in webview like this

enter image description here

But here I am geting Like this here no focus and no click option not working any thing give me some sugessions please..

enter image description here

this code useing display data in webview

 webview.getSettings().setJavaScriptEnabled(true);
 webview.loadDataWithBaseURL(null, string, "text/html", "utf-8", null);
like image 687
NagarjunaReddy Avatar asked Jan 29 '13 05:01

NagarjunaReddy


People also ask

How do I display HTML content in WebView?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken web view to show html content.

How can I get HTML content of URL open in Android WebView?

This can be achieved using below code. webview. setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { webview. loadUrl("javascript:window.

What is alternative of WebView in android?

Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.

Is Android WebView deprecated?

This interface was deprecated in API level 12. This interface is now obsolete.


1 Answers

Use Linkify.

Spannable sp = new SpannableString(Html.fromHtml(string));
Linkify.addLinks(sp, Linkify.ALL);
final String html = "<body>" + Html.toHtml(sp) + "</body>";
webView.loadData(html, "text/html", "utf-8");
like image 94
Rajesh Avatar answered Sep 17 '22 20:09

Rajesh