4

I like to recreate the behaviour of the textview containing the message of a user in the g+-app in my android project. To be exact: - on click on a link the link is visually selected (blue selector) and will open up in the browser - on click on normal text the whole list item is selected

The main problem I have, is, that every approach I tried to make links clickable (via xml and autolink=web, or in code) ends up, that the link opens up in a browser on click, but when I touch normal text in this textview the item is not selected (no selector is visible). I read many threads about this issue, but all the solutions, like add setFocusable(false), etc. doesn't work for me.

So I want to ask, if there is any tutorial, how to or example, where I can see how this things work, or do you have any idea how I can get it to work?

Thanks! :)

Tek
  • 489
  • 3
  • 13

1 Answers1

0

if you have email id in textview use below code..

TextView email = (TextView)findViewById(R.id.TextView04);
email.setText("sasd asd@gmai.com sadasd");
email.setLinkTextColor(Color.WHITE);
Linkify.addLinks(email,Linkify.EMAIL_ADDRESSES);

if you have url in textview use below code...

TextView tv = (TextView)findViewById(R.id.TextView04);
tv.setText("sasd https://asd.com sadasd");
tv.setLinkTextColor(Color.WHITE);
Linkify.addLinks(tv,Linkify.WEB_URLS);
Ishu
  • 5,357
  • 4
  • 16
  • 17