ベース アダプタがあり、ベース アダプタの getView() には 3 つのビューがあります。2 つのテキストビューと 1 つの削除ボタン。
最初のテキスト ビューは製品の名前、2 番目のテキスト ビューはカウンター (ショッピング カートから購入した製品の数)、3 番目は削除ボタンです。
たとえば、シャツ 2 個の delete_button スプーン 1 個の delete_button 食器 3 個の delete_button とします。
さて、問題は、最初の削除ボタンをクリックすると、最後のテキストビューの値が減少することです。
以下は私のコードです。
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View v = convertView;
if(v == null) {
v = inflater.inflate(R.layout.shop_billing_row_layout, parent, false);
txt_product_name = (TextView) v.findViewById(R.id.txt_view_product_name);
txt_count = (TextView) v.findViewById(R.id.txt_count);
btn_delete = (Button) v.findViewById(R.id.btn_delete_prodcut);
btn_delete.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
Log.i("Test", "******** position delete: " + position);
if(array_list_products.get(position).getCounter() > 0) {
if(array_list_products.get(position).getCounter() != 1) {
array_list_products.get(position).setCounter(array_list_products.get(position).getCounter() - 1);
txt_count.setText("");
txt_count.setText("" + (array_list_products.get(position).getCounter() - 1));
}
}
}
});
問題は、テキストビューが最後の位置にあり、最初の位置にある削除ボタンをクリックしているため、最後のテキストビューの値が減っていることだと思います。