我有一个带有列表视图的活动,列表视图是在列表视图适配器中创建的,所以在另一个类中。如何设置 onItemClick 上的多个操作仅针对每个列表项触发一次?我想更改单击的列表项的图像源,如果在 listView 适配器中设置,我如何从我的活动中访问它?
以下是 List View Adapter 中的一些代码,其中设置了 ListView 中的 Items:
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ListCell cell;
if (convertView == null) {
convertView = inflater.inflate(R.layout.get_all_entry_list_view_cell, null);
cell = new ListCell();
cell.note = (TextView) convertView.findViewById(R.id.listViewNote);
cell.img = (ImageView) convertView.findViewById(R.id.listViewImg);
convertView.setTag(cell);
}
else {
cell = (ListCell)convertView.getTag();
}
//.....Content is set with JSONObject from databse
public class ListCell {
private TextView note;
private ImageView img;
}