2

I have message having anchor tag.I want to show the word in anchor tag in different color in textview and onclick of that word start different activity.

I have tried textview.settext(Html.fromHtml(message)); it changes color but i also want onclick event on that. Is it posssible to do?

Sandeep R
  • 2,284
  • 3
  • 25
  • 51
Mario
  • 145
  • 2
  • 16
  • 2
    I dont want textviews onclick event, Inside textview only one word should be clickable that should start other activity.Like anchor tag in HTML – Mario Jan 15 '14 at 06:07

1 Answers1

1

Have a look here :

how to make anchor tag in android clickable

How do I make links in a TextView clickable?

How can I make links in fromHTML clickable? (Android)

Edit :

Ummm, well there are multiple ways to do that, you could use a custom url scheme to start the activity. If you need info regarding that, I have written a tutorial on my blog here :

http://myandroidtuts.blogspot.in/2013/07/custom-url-scheme-in-android.html

You could implement a onClickHandler :

   textView.setOnClickListener(new View.OnClickListener{
   public void onClick(View v){
         Intent intent = new Intent(this, OtherActivity.class);
         startActivity(intent);
   }
});
Community
  • 1
  • 1
Adnan Mulla
  • 2,872
  • 3
  • 25
  • 35
  • The links are related to webpages. I want same behaviour as anchor tag in html but instead of loading webpage in link i want to start new activity. – Mario Jan 15 '14 at 07:04
  • Edited my answer, check now – Adnan Mulla Jan 15 '14 at 07:09
  • The above code is for onclick of textview,but i want onclick of text inside textview.Suppose I have "Hello World" inside Textview,so onclick of only "World" i want to start a new activity not onclick of "Hello World". – Mario Jan 17 '14 at 11:53
  • You will have to either break up the text in 2 textviews or use custom url scheme – Adnan Mulla Jan 17 '14 at 12:01