I am trying to develop a simple order app.
Here I want to add/cancel the product
So, Finally I found the solution for scroll issue..
vi.setOnClickListener(new OnItemClickListener(position));
final int pos = position;
holder.button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
View parentView = (View) v.getParent();
int totAmount = Integer.parseInt(((TextView) parentView
.findViewById(R.id.text1)).getText()
.toString());
count = Integer.parseInt(((TextView) parentView
.findViewById(R.id.counter)).getText().toString());
count++;
tot_amt = totAmount * count;
((TextView) parentView.findViewById(R.id.counter))
.setText(String.valueOf(count));
((TextView) parentView.findViewById(R.id.totalPrice))
.setText(String.valueOf(tot_amt));
//Here I am saving the total amount and quantity
tempValues = null;
tempValues = (ListModel) data.get(pos);
tempValues.setProductName(tempValues.getProductName());
tempValues.setPrice(tempValues.getPrice());
tempValues.setImage(tempValues.getImage());
tempValues.setQuantity(String.valueOf(count));
tempValues.setTotalAmount(String.valueOf(tot_amt));
data.set(pos, tempValues);
ListViewExample sct = (ListViewExample) activity;
sct.getAllValues();
}
});
holder.decreesButton2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
View parentView = (View) v.getParent();
int totAmount = Integer.parseInt(((TextView) parentView
.findViewById(R.id.text1)).getText()
.toString());
count = Integer.parseInt(((TextView) parentView
.findViewById(R.id.counter)).getText().toString());
if (count > 0) {
count--;
tot_amt = totAmount * count;
((TextView) parentView.findViewById(R.id.totalPrice))
.setText(String.valueOf(tot_amt));
((TextView) parentView.findViewById(R.id.counter))
.setText(String.valueOf(count));
//Here I am saving the total amount and quantity
tempValues = null;
tempValues = (ListModel) data.get(pos);
tempValues.setProductName(tempValues
.getProductName());
tempValues.setPrice(tempValues.getPrice());
tempValues.setImage(tempValues.getImage());
tempValues.setQuantity(String.valueOf(count));
tempValues.setTotalAmount(String.valueOf(tot_amt));
data.set(pos, tempValues);
ListViewExample sct = (ListViewExample) activity;
sct.getAllValues();
}
}
});
Thanks Longi..!!