I would like to know if and how it is possible to add a web link to a TextView widget. In my app, i show some text and adjacent to this text an image. I would like to insert a clickable internet link in the text. Is this possible?
In Android, the most common way to show a text is by TextView element. The whole text in the TextView is easy to make clickable implementing the onClick attribute or by setting an onClickListener to the TextView.
Create a hyperlink to a location on the webSelect the text or picture that you want to display as a hyperlink. Press Ctrl+K. You can also right-click the text or picture and click Link on the shortcut menu. In the Insert Hyperlink box, type or paste your link in the Address box.
You just need to set the android:autolink property.
<TextView
android:autoLink="web"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="http://www.google.com" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With