我想在列表视图单击事件上更改 Textview 颜色和 Imageview 图像,并且我还创建自定义列表视图。我希望当我单击列表视图项目以更改图像和文本颜色并转到另一个活动时,但是当我返回列表活动时并单击其他列表项以更改文本颜色和图像以及更改第一次单击项颜色和图像..我的代码如下:
SimpleAdapter adapter = new SimpleAdapter(getBaseContext(),
channel_listView, R.layout.listview_layout1, from, to);
listView.setDivider(null);
listView.setAdapter(adapter);
listView.setCacheColorHint(0);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
// TODO Auto-generated method stub
long c_name = listView.getItemIdAtPosition(position);
Log.i("c_name", "" + c_name);
((TextView) arg1.findViewById(R.id.txt))
.setTextColor(Color.YELLOW);
((ImageView) arg1.findViewById(R.id.flag))
.setBackgroundResource(R.drawable.yellowmusicicon);
String ch_name = (String) ((TextView) arg1
.findViewById(R.id.txt)).getText();
Log.i("txt_value", "" + ch_name);
Intent intent = new Intent(ChannelList.this,
FMActivity.class);
intent.putExtra("id", c_name);
intent.putExtra("c_name", ch_name);
startActivity(intent);
}
});