how open google home page on click on hyperlink text view in android trying out following code on click on hyperlink changing normal text how resolve
here code:
mainactivity.java (in oncreate() )
instruction = (textview) findviewbyid(r.id.example); instruction.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { instruction.settext(html.fromhtml(getstring(r.string.google_instructions))); linkify.addlinks(instruction, linkify.all); instruction.setmovementmethod(linkmovementmethod.getinstance()); } }); strings.xml
<string name="google_instructions">opens <a href="https://www.google.co.in">google</a> page </string> layout_test.xml
<textview android:id="@+id/example" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="10sp" android:clickable="true" android:text="@string/google_instructions" android:autolink="web" android:textsize="16sp" />
hi got solution using adding small piece of code in java class , little changes in layout xml file
instruction = (textview) findviewbyid(r.id.example); instruction.settext(html .fromhtml("<b> open google console </b> " + "<a href=\"https://code.google.com/apis/console\">click here</a> ")); instruction.setmovementmethod(linkmovementmethod.getinstance()); layout_test.xml
<textview android:id="@+id/example" android:layout_width="match_parent" android:layout_height="match_parent" />
Comments
Post a Comment