I want to make a link for a textview text like Google. Is there anyway to make link like this. (i.e) When clicking on the word Google it should open the appropriate link. Any ideas are welcome.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Note :- Html.fromHtml is deprecated in Android N
You need to do check and support
Android N
and higher versions of AndroidAlternatively
You can don't want to id programmatically add autoLink flag on TextView.
This way You don't need to add
<a href='somelink'>
tags.Which is a disadvantage, if you want to add
hyperlink
on atext
you can't do it this way. eg you can't do something like this:- [hiteshsahu][1]The result from both approach:-
https://github.com/hiteshsahu
All tested and working 100%
Solution:
android:autoLink="web"
below is a complete example
Sample Layout Xml
String in string.xml
This can also be done by using the default property of Textview
Try this, and let me know what happen..
Using java code:
From API level >= 24 onwards
Html.fromHtml(String source)
is deprecated instead usefromHtml(String, int)
,Or in layout xml file, inside your TextView widget attributes
For Latest version of SDK
fromHtml
is deprecated Use below lineuse
android:autoLink="web"
in your TextView's xml. It should automatically convert urls click-able (if found in text)