Textview's Value Changed While Scrolling Listview
I am using listview to populate data.Everything is fine until scroll it. While scrolling all the textview (COUNT) is changed to default value. Here I am using Cursor adapter to pop
Solution 1:
For REMOVE : Create custom OnClickListener which takes cartProduct as its parameter
publicclassCustomOnClickimplementsOnClickListener {
String product;
publicCustomOnClick(String product) {
super();
this.product = product;
}
@OverridepublicvoidonClick(View v) {
// TODO Auto-generated method stub
dbUtil.open();
String delItem = product; //set product to delItemCursorCartcursor = dbUtil.getCartID(delItem);
if (Cartcursor != null && Cartcursor.moveToFirst()) {
Cartcursor.moveToFirst();
String strCartProductID = Cartcursor.getString(Cartcursor.getColumnIndex(DbHelper.CART_PDT_ID));
dbUtil.deleteCart(strCartProductID, delItem);
Toast.makeText(contextNew, "Cart Item " + "RowId" + strCartProductID + " Product Id" + delItem, Toast.LENGTH_SHORT).show();
Toast.makeText(contextNew, "Deleted Successfully", Toast.LENGTH_SHORT).show();
}
}
}
then while setting onclicklistener to remove button you can try
viewHolder.remove.setOnClickListener(new CustomOnClick(cursor.getString(cursor.getColumnIndex(DbHelper.CART_PDT_NAME))));
And for storing COUNT values when you loading listview add value in HashMap (which stores product name and count against it), after whenever you increase or decrease COUNT just update its value in hashmap
Post a Comment for "Textview's Value Changed While Scrolling Listview"