I have multiple textviews. And all textviews are one word. I want to build a paragraph by using them. But they should not lose their textview feature. So they should not be used as string. Because then, I want them to be clickable one by one.
Asked
Active
Viewed 122 times
2 Answers
0
You can use a single textview and spannable string to make the words clickable separately.

NIKHIL AGGARWAL
- 448
- 4
- 9
-
Thanks for your help. But I cant differentiate spannable string ID's. Just like my example: https://stackoverflow.com/questions/60930415/could-we-define-unknown-amount-of-clickable-texts-which-have-different-outputs-i – Baris Mar 30 '20 at 18:07
0
TextView textview1,textview2,textview3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.activity_main);
textview1 = findViewById(R.id.textview1);
textview2 = findViewById(R.id.textview2);
textview3 = findViewById(R.id.textview3);
textview1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//
}
});
textview2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//
}
});
textview3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//
}
});
}

Shimaa Yasser
- 587
- 4
- 12
-
Thanks for your help. But I want whole words have different ID to click. And when I click on words, I want them all (all words) do different thing(ex: they show which word they are) – Baris Mar 30 '20 at 18:11
-
Okay, my answer is an example of what you should do, you need to treat every single word as a separated textview – Shimaa Yasser Mar 30 '20 at 18:31
-
Thanks for your return. But I dont know their numbers, so I should make textview programmatically in for-loop. And the main problem is how I can concatenate them like paragraph. Now, I try flex box. – Baris Mar 30 '20 at 18:47
-
-
-
-
Flex Box helped me to achieve. But your ways are in my mind. I will try both of them. Thank you. – Baris Mar 30 '20 at 19:22