hi i made a program that when i input number in my editText it will automatically display tablerow that contains edittexts equal to the number that i inputted, i made use of for loop to do this, but i want that in every loop it will change the background color of the edittext how will i do that, thanks in advance...
here are my codes...
final EditText et = (EditText)findViewById(R.id.questions);
Button button1 = (Button)findViewById(R.id.btn);
button1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String c = et.getText().toString();
Integer count = Integer.parseInt(c);
TableLayout table = new TableLayout(getApplicationContext());
table.setVerticalScrollBarEnabled(true);
table.setPadding(10, 10, 10, 10);
TableRow tableRow = new TableRow (getApplicationContext());
TextView txt = new TextView (getApplicationContext());
TextView txt2 = new TextView (getApplicationContext());
TextView txt3 = new TextView (getApplicationContext());
TextView txt4 = new TextView (getApplicationContext());
TextView txt5 = new TextView (getApplicationContext());
TextView txt6 = new TextView (getApplicationContext());
tableRow.addView(txt);
tableRow.addView(txt2);
tableRow.addView(txt3);
tableRow.addView(txt4);
tableRow.addView(txt5);
tableRow.addView(txt6);
txt.setText("Question ");
txt2.setText("Excellent ");
txt3.setText("Best ");
txt4.setText("Better ");
txt5.setText("Good ");
txt6.setText("Poor ");
table.addView(tableRow);
int j=0;
for(j = 1; j<=count; j++){
tableRow = new TableRow (getApplicationContext());
TextView name = new TextView (getApplicationContext());
EditText et2 = new EditText (getApplicationContext());
EditText et3 = new EditText (getApplicationContext());
EditText et4 = new EditText (getApplicationContext());
EditText et5 = new EditText (getApplicationContext());
EditText et6 = new EditText (getApplicationContext());
et2.setBackgroundColor(Color.WHITE);
et3.setBackgroundColor(Color.WHITE);
et4.setBackgroundColor(Color.WHITE);
et5.setBackgroundColor(Color.WHITE);
et6.setBackgroundColor(Color.WHITE);
tableRow.addView(name);
tableRow.addView(et2);
tableRow.addView(et3);
tableRow.addView(et4);
tableRow.addView(et5);
tableRow.addView(et6);
table.addView(tableRow);
}
setContentView(table);
}
});