I'd like to ask you what global code do I have to create to highlight text when pressed in various places of the app. Or do I have to just add color line to onClick method in every single text body which is going to be highlighted?
Thanks for your advice.
To be more specific with my question, just have a look at this code:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView text = (TextView) findViewById(R.id.textView2);
text.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
text.setTextColor(Color.GREEN);
}
});
}
}
I have 54 answers in sets of 3 answers on every page/screen and have to use the same method for each answer - being highligted when pressed. I wonder how can I do it properly. If I add to findViewById(R.id.textView2); another text id right after textView2 this isn't working.