java - HTTP links in alert dialog not working -


i tried following following example make http link in textview in alert dialog clickable, not work:

how make links in textview clickable?

the way can work if put text of link directly string , put android:autolink="web" textview. not want see whole link, name.

here dialog created:

@override protected dialog oncreatedialog(int id) {     layoutinflater factory = layoutinflater.from(this);      switch (id) {     case disclaimer:             final view disclaimerview = factory.inflate(r.layout.disclaimer_dialog, null);             final textview dtv = (textview) disclaimerview.findviewbyid(r.id.disclaimer_body);              dtv.settext("v"+versionname+"\n\n\u00a9"+calendar.getinstance().get(calendar.year)+" "+"developer\n\n" +                 getstring(r.string.alert_dialog_disclaimer_body));              dtv.setmovementmethod(linkmovementmethod.getinstance());                              return new alertdialog.builder(myactivity.this)                                 .setview(disclaimerview)                 .setpositivebutton(r.string.alert_dialog_ok, new dialoginterface.onclicklistener() {                     public void onclick(dialoginterface dialog, int whichbutton) {                     }                 })                 .create();     }      return null; } 

here textview located in r.layout.disclaimer_dialog:

<textview     android:id="@+id/disclaimer_body"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_margintop="5dp"     android:layout_marginbottom="10dp"     android:gravity="center"     /> 

here string resource:

<string name="alert_dialog_disclaimer_body">this application developed , written me.\n\ngraphs use achartengine licensed under <a href="http://www.apache.org/licenses/license-2.0">apache license 2.0</a>.\n\nthe rest goes here.</string> 

the documentation textview.settext(charsequence) explains:

sets string value of textview. textview not accept html-like formatting, can text strings in xml resource files. style strings, attach android.text.style.* objects spannablestring, or see available resource types documentation example of setting formatted text in xml resource file.

and following suggestion, formatting , styling explains, under styling html markup heading, how can have both html markup , formatting codes.

i think easiest thing in situation adjust layout have copyright notice in 1 view use are, , put disclaimer below in second view leave alone:

<textview     android:id="@+id/disclaimer_body"     android:text="@string/alert_dialog_disclaimer_body"     ...     /> 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -