I want to implement a textview in the middle of a small paragraph of text into a hyperlink, click to call the system's default browser, jump to the specified page such a function. Oneself first toss a bit did not fix, and saw a lot of information on the net, many say in code with what spanned, html.fromhtml () and so on to set TextView, make quite complex, and then add Android to TextView in the layout: autolink= "Web", android:linksclickable= "true" what, but various methods I have tried, do not know why, incredibly all is shit! There is no response after the click.
Finally helpless still have to StackOverflow check a bit, the result found positive solution! And it's a lot easier to achieve than most people say! Needless to say, I immediately put the implementation method to the following:
1) First in the Strings.xml file directly in the TextView to display the hyperlink text, such as, the hyperlink with the HTML tag of the wording to the line
<string name= "Signup_agreeterms" > I agree <a href= "http://www.baidu.com/" > All content in User Agreement </a> </string >
2) Then you have to have a textview in the layout, notice, don't add any more autolink, linksclickable attributes, etc.
<textview android:id= "@+id/signup_txt_agreeterms" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:text= "@string/signup_agreeterms"/>
3) In your activity, add the following code
TextView TextView = (TextView) Findviewbyid (r.id.signup_txt_agreeterms); Textview.setmovementmethod (Linkmovementmethod.getinstance ()); Actually, that's the key.
This is OK, it is too simple ...
Attached to the reference StackOverflow address: How does I make links in a TextView clickable?
Ultra-simple implementation of TextView in a text hyperlink click Open Browser to jump to the Web page