我的列表视图包含 2 个 TextViews 和一个 ImageView。我使用了一个适配器来填充 ListView。当我单击一个行项目时,我希望位于单击项目的背景图像进行更改。我正在使用如下所示的 setOnItemClickListener()
lvRMultiple.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
mp3Url = trackList.get(position).getPreview().toString();
title = trackList.get(position).getTitle().toString();
playStreamMusic();
Toast.makeText(getBaseContext(), "Item Clicked :)", Toast.LENGTH_LONG).show();
}
});
我的 getView() 方法如下:
public View getView(int position, View convertView, ViewGroup parent) {
vi = convertView;
if (convertView == null) {
vi = inflater.inflate(R.layout.ecran_multiple_row, null);
holder = new ViewHolder();
holder.txIndex = (TextView) vi.findViewById(R.id.txIndex);
holder.txSTitle = (TextView) vi.findViewById(R.id.txSTitle);
holder.btOnOFF = (ImageView) vi.findViewById(R.id.btOnOFF);
vi.setTag(holder);
} else
holder = (ViewHolder) vi.getTag();
return vi;
}
}
如何更改项目选择的 imageView 背景?