android - Hyperlink in string resource in AlertDialog -


i have large string , need add 2 hyperlinks. did it, it`s not clickable.

string:

<string name="freeasa"><![cdata[<b><font color=#cc0022>text<font color=#2266bb> text </font></b> <br> text <a href=\'http://google.com\'>navigate google.com</a><br><b><font color=#2266bb> text</font><font color=#cc0022> text </font></b><br> text <a href=\'http://yahoo.com\'> yahoo link<\a> ]]></string> 

alertdialog:

        final alertdialog.builder builder = new alertdialog.builder(getcontext());         builder.settitle(getresources().getstring(r.string.add_info));         builder.setmessage(html.fromhtml(getresources().getstring(r.string.freeasa)))                 .setpositivebutton("ok", new dialoginterface.onclicklistener() {                     @override                     public void onclick(dialoginterface dialoginterface, int i) {                         dialoginterface.dismiss();                     }                 }).show(); 

there hyperlinks, not clickable. how fix ? enter image description here

try custom alert dialog below way

enter image description here

layoutinflater li = layoutinflater.from(mainactivity.this);         view promptsview = li.inflate(r.layout.prompts, null);          final alertdialog.builder builder = new alertdialog.builder(mainactivity.this);         builder.setview(promptsview);         final textview userinput = (textview) promptsview                 .findviewbyid(r.id.textview);         userinput.setmovementmethod(linkmovementmethod.getinstance());         userinput.settext(html.fromhtml(getresources().getstring(r.string.about_body)));         builder.settitle(getresources().getstring(r.string.app_name));         // builder.setmessage(html.fromhtml(getresources().getstring(r.string.about_body)))         builder.setpositivebutton("ok", new dialoginterface.onclicklistener() {             @override             public void onclick(dialoginterface dialoginterface, int i) {                 dialoginterface.dismiss();             }         }).show(); 

prompts.xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"     android:padding="10dip">      <textview         android:id="@+id/textview"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:clickable="true"         android:text="medium text"         android:textappearance="?android:attr/textappearancemedium" /> </linearlayout> 

make sure string correct , links working


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -