0

I am trying to make a application that will allow people to tag more people. I want to make such that when a person clicks / taps in the name of another person in the TextView, it should go to the person's profile in the application (but not in the web). How can I make it?

Any insight of how to do would be respected!

A short code of how to do would be much respected!

TextView Content Example: I am here in the city with Manoj and he is enjoying this place.

I want to make this such that when a person clicks Manoj it should be gone to the next fragment or next activity. And the data should is to sent to the server, so it is something We cant just use only onClick Listener for the text, as the text is determined and the link is created by public user not me?

The image would help you understand!

  • [This might help you](https://stackoverflow.com/questions/10696986/how-to-set-the-part-of-the-text-view-is-clickable) – Håkon Schia Dec 12 '20 at 19:11
  • @HåkonSchia thanks for your insight, this would really be working if I would have been working on a static content, but in my context the content is dynamic users can post their own content, and I want to make such that they can add their own links to other fragments or activities. You can just think it like as facebook post content with some #Link, where user can post their content and on other people clicking on the #Link it should change its fragment or activity! – Kishor Kumar Neupane Dec 13 '20 at 02:53

1 Answers1

0

First in your java file find your TextView by xml id

TextView tv = (TextView)findViewById(R.Id.textView);

then, you have to set click listner on the textView

tv.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
      // here you can use intent to naviaget to another activity
   }
});
Manoj Kumar
  • 332
  • 1
  • 7
  • Thanks for your insight @Manoj but I wanted to do something else. I have a text View and it is to be saved in the server. Hello World this is a text view. I want to make that when a person clicks on the World it should move in the next activity or fragment. and the text is to be sent to the server so that other people can also use the same click listener in the application! – Kishor Kumar Neupane Dec 12 '20 at 17:07
  • you can also get the text of the textview by using ''tv.gettext.toString" in string formate an d send this string to the server. – Manoj Kumar Dec 12 '20 at 17:15
  • this would not work. I am trying to create something like twitters post to say in simple, where you can mention people, and the persons name would be work to move to the next fragment. It would be in any point in the text and any number of times! – Kishor Kumar Neupane Dec 13 '20 at 06:38