I find myself repeating the same lines of code, and I'd like to automate this a bit.
I'm doing the following to change the color of text in a view to correspond with correct/incorrect answers:
((CheckBox) findViewById(R.id.quiz_answer_2e)).setTextColor(Color.parseColor("#EE7674"));
I'd like to pass in parameters so I don't have to repeat this, I would prefer to call the function and set parameters to the function like:
public void setCorrect(String viewType, String viewName, String thisColor) {
if (thisColor.equals("red")) {
thisColor = "#EE7674";
} else {
thisColor = "#9DBF9E";
}
((**viewType**) findViewById(R.id.**viewName**)).setTextColor(Color.parseColor(**thisColor**));
}
Where viewType, viewName and thisColor are passed to the method. Is there a way to do this?
I tried saving the value to a String, but couldn't determine how to get that string to run from the method.
Thanks in advance.