기본 어댑터가 있고 기본 어댑터의 getView() 뷰가 세 개 있습니다. 2 textviews 및 하나의 삭제 버튼.목록보기 어댑터 in 안드로이드
첫 번째 텍스트보기는 제품 이름이고, 두 번째 텍스트보기는 카운터입니다 (얼마나 많은 제품이 장바구니에서 종류가 구매되었는지). 세 번째는 삭제 단추입니다.
예 : 셔츠 2 delete_button 숟가락 1 delete_button utencils 3 delete_button.
이제 첫 번째 삭제 버튼을 클릭하면 마지막 textview의 값이 감소합니다.
다음은 제 코드입니다.
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));
}
}
}
});
나는 문제가 텍스트 뷰가 마지막 위치에있다 생각하고, 나는 처음 위치에 따라서 마지막 텍스트 뷰의 값을 감소시키는됩니다에있는 삭제 버튼을 클릭하고 있습니다. setOnClickListener()에서
에 위치 태그를 설정하는 것입니다 시도 할 수 있습니다 ? –
첫 번째 삭제 버튼을 클릭하면 카운터 값이 1 씩 감소합니다. 값이 감소하지만 표시 할 때 첫 번째 카운터 텍스트보기가 아닌 마지막 카운터 텍스트보기에 표시됩니다 –