3つのテキストボックスと各行に1つのチェックボックスがあるlisviewがあります。次のコードスニペットを使用して、チェックされたチェックボックスの正確な位置を取得しました。これはうまく機能しましたが、今は入れたくない listView.setOnItemClickListener
ので、リストビューの項目や行をクリックするのではなく、ボタンでチェックした項目を削除したいのですが、目標を達成するためにこれらのコードをどこに配置すればよいかわかりません。事前に懸念や提案をいただければ幸いです。
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
CheckBox cbx = (CheckBox)view.findViewById(R.id.ChkOrder);
int firstPosition = listView.getFirstVisiblePosition();
for(int i=firstPosition;i<listView.getCount();i++){
View v=listView.getChildAt(i);
cbx = (CheckBox)v.findViewById(R.id.ChkOrder);
if(cbx.isChecked()){
Toast.makeText(getApplicationContext(),
"Checked position " + goods.get(i),
Toast.LENGTH_SHORT).show();
checkedItemPosition=i;
}
}
}
});