0

カスタム アダプターを使用して設定されたリストビューがあります。リスト ビューには 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);  
                     }
                }
            })
4

1 に答える 1

0

答えが見つかりました。位置を取得し、位置の値と notifydatasetchanged() を持つ両方のリストを削除します

于 2012-12-02T11:32:32.373 に答える