android - Link in alert dialog fragment -


i'm using code show simple dialog link:

  string msg = "http://www.google.com"   final spannablestring s = new spannablestring(msg);   linkify.addlinks(s, linkify.all);   fragment dialogfrag = mydialogfragment.newinstance(title, msg);   getfragmentmanager().begintransaction().add(dialogfrag, key).commit(); 

the mydialogfragment class:

public class mydialogfragment extends dialogfragment {  public static mydialogfragment newinstance(string title, string message) {     mydialogfragment frag = new mydialogfragment();     bundle args = new bundle();     args.putstring("title", title);     args.putstring("msg", message);     frag.setarguments(args);     return frag; }  @override public dialog oncreatedialog(bundle savedinstancestate) {     string title = getarguments().getstring("title");     string msg = getarguments().getstring("msg");      return new alertdialog.builder(getactivity())             .settitle(title)             .setmessage(msg)             .setpositivebutton(android.r.string.ok, null)             .create(); } } 

the dialog doesn't show hyperlink. i'm using android 5.0.1 without support libraries.

build textview containing message spannablestring:

string title = getarguments().getstring("title"); string msg = getarguments().getstring("msg");  final textview textview = new textview(getactivity(); final spannablestring spannablemsg = new spannablestring(msg);  linkify.addlinks(spannablemsg, linkify.web_urls);  textview.settext(spannablemsg); textview.setmovementmethod(linkmovementmethod.getinstance()); 

and add textview instead of assigning text:

return new alertdialog.builder(getactivity())         .settitle(title)         .setview(textview)         .setpositivebutton(android.r.string.ok, null)         .create(); 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -