Android: Changing the Object Fields with its own Earphone

advertisements

I have several radio buttons, each of which has a View.OnClickListener. The whole purpose of those listeners are for me to be able to change the color of the text associated with the RadioButton upon clicking this very RadioButton. My problem is, I'm not sure how to do that.

Here is how I set a listener for each RadioButton:

radioButton.setOnClickListener(badAnswerListener());

Here's the badAnswerListener method:

private View.OnClickListener badAnswerListener(){
     return new View.OnClickListener() {
         @Override
         public void onClick(View arg0) {
             //How do I change the radioButton's color?

         }
     };
}


If radioButton is private member of class :

radioButton.setTextColor(R.color.customcolor);

See this too, it's almost the same question :

Changing Text color of RadioButton if clicked in android