i am using Edittexts in my application. but not able to set their background color at runtime. If i am doing something wrong then please suggest.
i have taken three edittexts which should change their color according to if codition used in the do while loop. please check and do response ASAp. thanks in advance.
here is my code.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
List<Map<String,String>> list = new ArrayList<Map<String,String >>();
EditText ed1 = (EditText) findViewById(R.id.name);
EditText ed2 = (EditText) findViewById(R.id.age);
EditText ed3 = (EditText) findViewById(R.id.date);
Map<String,String> map = new HashMap<String, String>();
int i = 2;
EmpDatabase empClick = new EmpDatabase(getApplicationContext());
Cursor cursor = empClick.getDetails();
if(cursor.moveToFirst()){
do{
i= i+1;
if(i % 2 == 0)
{
// here is something wrong
ed1.setBackgroundColor(Color.BLUE);
ed2.setBackgroundColor(Color.BLUE);
ed3.setBackgroundColor(Color.BLUE);
}
else
{
// here is something wrong
ed1.setBackgroundColor(Color.CYAN);
ed2.setBackgroundColor(Color.CYAN);
ed3.setBackgroundColor(Color.CYAN);
}
map = new HashMap<String, String>();
String name = cursor.getString(cursor.getColumnIndex("name"));
String age = cursor.getString(cursor.getColumnIndex("age"));
String time = cursor.getString(cursor.getColumnIndex("time"));
map.put("name",name);
map.put("age",age);
map.put("time", time);
list.add(map);
}while(cursor.moveToNext());
cursor.close();
}
SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.text_view, new String [] {"name", "age", "time"}, new int[] {R.id.name,R.id.age, R.id.date});
setListAdapter(adapter);
}