In my android application there is a table layout which is loaded at run time. I set an OnClickListener for table rows.
tr.setClickable(true);
tr.setOnClickListener(trOnClickListener);
I need to change the background color of the table row when it is clicked. This is my onClick method.
private OnClickListener trOnClickListener = new OnClickListener() {
public void onClick(View v) {
TableRow tablerow = (TableRow)v;
tablerow.setBackgroundDrawable(getResources().getDrawable(
R.drawable.ab_stacked_solid_whiteaction));
}
};
When I click a table row it changes the background color. When I click another row it also changes its' background color. But what I want is, should be changed background color of only one row at a time.
How can I do that ? Any suggestions are appreciated.
Thanks in advance