My code is like this...
public class MainActivity extends Activity {
String a = new String("1,2,3,4,5")
private Button button1;
private Button button2;
private Button button3;
private Button button4;
private Button button5;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startBtn = (Button) findViewById(R.id.startBtn);
startBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
String[] splited=a.split(",");
for(String b : splited){
(button"b").setBackground(Color.RED);
//This is the part where I get stucked//
//I know the code is wrong but I just want to express my idea//
}
}
});
}
}
So,how can I name the button with a changing String b?
The button1 should changing its background color first, then button2, button3, and so on.
Any ideas?