I have a couple of buttons like
font1 = (Button)findViewById(R.id.fontsize1);
font2 = (Button)findViewById(R.id.fontsize2);
When I click on a button I want to change its textcolor and also change the textcolor of the rest of the buttons. Of course I do not want to write many lines best practice is a loop.
font1.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
SaveFontSize("fontsize", "font1");
font1.setTextColor(Color.parseColor(color_active));
font1.setBackgroundResource(R.drawable.fonturesgreen);
}
}
});
I created a list:
List<String> fontarray = Arrays.asList("font1", "font2", "font3", "font4", "font5");
And in the loop I tried to do this:
for (int i=0; i<5; i++) {
fontarray.get(i).setTextColor(Color.parseColor(color_active));
}
This gives me an error, since fontarray.get(i) is a String, not a button.