リストビューを使用したアクティビティがあります。リストビューはリストビューアダプターで作成されるため、他のクラスで作成されます。onItemClick のいくつかのアクションが各リスト項目に対して 1 回だけ実行されるように設定するにはどうすればよいですか? クリックされたリスト項目の画像ソースを変更したいのですが、listView アダプターで設定されている場合、アクティビティからどのようにアクセスできますか?
ListView にある項目が設定されている List View Adapter のコードを次に示します。
@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;
}