カスタム アダプターを使用して設定されたリストビューがあります。リスト ビューには 2 つのリストと 1 つの画像が含まれています。.Format- list list image
そのボタンがクリックされたときに、両方のリストから同時にアイテムを削除したい。
使っonclick
てみonitemclick
ましたが、アプリがクラッシュしました。
両方のリストを同時に削除するにはどうすればよいですか?リストはデータベースに保存されません。アイテムはVector
.
インデックスとビューの使用は何ですか? カスタム アダプターが拡張Base Adpater
されると、パラメーター位置を含むgetView メソッドを取得します。これはインデックス値と同じですか?
code-holder.imgBtn.setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View arg0) {
Index index = (Integer) arg0.getTag();
if(index>=0){
prescriptionRemoval = ProgressDialog.show(AddToCartActivity.this, null, getResources().getString(R.string.prescriptionRemoval));
String removeDrug=drugNameList.get(index);
String removePrescription=prescriptionList.get(index);
String removeTotal=removeDrug+removePrescription;
listCheck.remove(removeTotal);
drugNameList.remove(index.intValue());
prescriptionList.remove(index.intValue());
notifyDataSetChanged();
handler.sendEmptyMessage(DIALOG_PRESCRIPTION_REMOVAL);
}
}
})