Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextView underline phone number and hyperlink

Tags:

android

I've written an app which contains a large textview for displaying notes. Is it possible to have the textview highlight any phone numbers or hyperlinks without underlining the entire view?

like image 374
Chris Avatar asked Jun 11 '10 21:06

Chris


People also ask

How do you underline text in TextView?

You can define the underlined text in an Android layout XML using a String Resouce XML file. In a string res file you have to use an HTML underline tag <u> </u> .

How do I make a phone number clickable on Android?

You can make a phone number a clickable link that opens a dial dialog on smartphones and mobile devices. To get started, highlight the number and click the Link button. Next, change the Protocol to <other> and paste the phone number into the URL box, with the prefix "tel:+" as shown below. Click OK when finished.

How do you make a string clickable?

tvSubmit. setMovementMethod(LinkMovementMethod. getInstance()); Spannable sp = (Spannable) tvSubmit. getText(); ClickableSpan click = new ClickableSpan() { @Override public void onClick(View widget) { showLink(); } }; sp.


1 Answers

<TextView     ...    android:autoLink="all" /> 

That's actually enough for you

like image 160
Fedor Avatar answered Oct 05 '22 03:10

Fedor