I have three Items in a ListView, and on each and every list item i have three TextView(s), one contains item price, second to show Quantity and third to show Total of that item.
Also two more TextView(s), one to increase the quantity and second to decrease the quantity.
Now the issue is whenever i make changes in quantity of first or second list item, it effects on quantity and total amount of third list item (i.e - Last item in a List)
public class CartAdapter extends BaseAdapter {
ViewHolder holder;
......
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// convert view = design
View v = convertView;
if (v == null) {
holder = new ViewHolder();
v = layoutInflater.inflate(Resource, null);
holder.textViewPrice = (TextView) v.findViewById(R.id.textPrice);
holder.editTextQuantity = (EditText) v.findViewById(R.id.editQuantity);
holder.textViewTotal = (TextView) v.findViewById(R.id.textTotal);
v.setTag(holder);
} else {
holder = (ViewHolder) v.getTag();
}
holder.textViewPrice.setText("$ " +cartArrayList.get(Integer.parseInt(holder.textViewPrice.getTag())).getPrice());
cart = cartArrayList.get(Integer.parseInt(v.getTag()));
holder.editTextQuantity.setText(String.valueOf(cart.getQuantity()));
df = new DecimalFormat("0.00##");
totalPrice = cart.getQuantity() * cart.getPrice();
cart.setTotal(totalPrice);
holder.textViewTotal.setText("$ " + df.format(cart.getTotal()));
return v;
}