0

When there is any address in string, showing in TextView, need to be clickable and open on maps.

I've tried tv.setAutoLinkMask(Linkify.ALL). It is not working for all addresses. enter image description here

Any other way that's make clickable and link all addresses in TextView?

Bills
  • 768
  • 7
  • 19
  • Does this answer your question? [How to make links in a TextView clickable](https://stackoverflow.com/questions/2734270/how-to-make-links-in-a-textview-clickable) – abdo Salm Sep 06 '22 at 09:13
  • I've tried all of these, no thing is working :( – Bills Sep 06 '22 at 09:33

2 Answers2

0

you can use simple on click listener.

 textView.setOnClickListener {
 //open google maps

 }

and for text to make it look like a link you can use:

    <string name="underline_text"><![CDATA[<u>underlined text</u>]]></string>

Also, you can use blue text color (#0D6EFD) to make it more professional.

Aiman Qaid
  • 41
  • 1
0

you can use Intent.ACTION_VIEW to open google map from your app. Something like this:

    tv.setOnClickListener {
        val address = tv.text
        val content = "geo:0,0?q=$address"
        val intent = Intent(Intent.ACTION_VIEW, Uri.parse(content))
        startActivity(intent)
    }

Here I'm using Kotlin, convert java if you want

ninhnau19
  • 695
  • 1
  • 3
  • 16