android - Anonymous bug in TextView -
i developing restaurant app. here use cart page view food items user selected checkout. cart items listed using recyclerview having + & - button increase & decrease product count before checkouts. problem @ here.
let consider items follows:
result textview chocobar rs25 - 4 + = 100 // expected result vennila rs30 - 1 + = 30
while clicking "+" button in chocobar
result textview chocobar rs25 - 5 + = 100 ( set 125 within fraction of second changed 100) vennila rs30 - 1 + = 30
but if use gettext,
resulttextview nothing in code used holder.cartpricedum
resulttextview.gettext().tostring --> returns 125 chocobar's item values.
gettext works settext not worked. gettting messup. please me, spent more time fix it.still have not fixed it.
mycode follows:
holder.ivincrease.setonclicklistener(new view.onclicklistener() { public void onclick(view arg0) { clicked = true; cartprice = integer.parseint(holder.cartprice.gettext().tostring()); indequantity = integer.parseint(holder.cartcount.gettext().tostring()); if (null != mlistener) { cartres.get(position).cartcount = (bigint + 1); notifyitemchanged(position); mlistener.onlistfragmentinteraction(holder.cartress); } updatecart(arg0); } private void updatecart(view view) { string pid = cartres.get(position).product_id; int cartprice = integer.parseint(holder.cartprice.gettext().tostring()); int cartindividualtotal = cartres.get(position).subtotal; int cartcount = cartres.get(position).cartcount; system.out.println("restaurant" + " check" + "product id " + pid + "cart price " + cartprice + " cartindividual total " + cartindividualtotal + " cartcount " + cartcount); commonutil.dbutil.open(); commonutil.dbutil.updateaddtocart(pid, cartprice, cartcount, cartindividualtotal); total = commonutil.dbutil.getmultiply(pid); commonutil.dbutil.updatenetamount(pid, total); setcartprice(pid, holder); view.invalidate(); /*--- set updated value cartres class---*/ system.out.println("cart details" + cartres.get(position).product_id + " " + cartres.get(position).cartproductname + " " + cartres.get(position).cartcategoryname + " " + cartcount + " " + cartprice + " " + total); cartres cartbasket = new cartres(cartres.get(position).product_id, cartres.get(position). cartproductname, cartres.get(position).cartcategoryname, cartcount, cartprice, total); } }); /*======================================= *** ==============================================*/ /*--- if cart count 1, disable decrement icon*/ if (indequantity <= 1) { holder.ivdecrease.setvisibility(view.invisible); } else { holder.ivdecrease.setvisibility(view.visible); } /*==================================== decreasing cart ====================================*/ holder.ivdecrease.setonclicklistener(new view.onclicklistener() { public void onclick(view arg0) { clicked = true; cartprice = integer.parseint(holder.cartprice.gettext().tostring()); indequantity = integer.parseint(holder.cartcount.gettext().tostring()); if (null != mlistener) { if (indequantity > 1) { cartres.get(position).cartcount = (bigint - 1); notifyitemchanged(position); mlistener.onlistfragmentinteraction(holder.cartress); } else if (indequantity <= 0) { indequantity = 1; } } updatecart(arg0); } private void updatecart(view view) { string pid = cartres.get(position).product_id; int cartprice = integer.parseint(holder.cartprice.gettext().tostring()); int cartcount = cartres.get(position).cartcount; int cartindividualtotal = cartres.get(position).subtotal; commonutil.dbutil.open(); commonutil.dbutil.updateaddtocart(pid, cartprice, cartcount, cartindividualtotal); system.out.println("restaurant " + pid + " " + cartprice + " " + cartcount + " " + cartindividualtotal); total = commonutil.dbutil.getmultiply(pid); commonutil.dbutil.updatenetamount(pid, total); setcartprice(pid, holder); view.invalidate(); system.out.println("cart details" + cartres.get(position).product_id + " " + cartres.get(position).cartproductname + " " + cartres.get(position).cartcategoryname + " " + cartcount + " " + cartprice + " " + total); cartres cartbasket = new cartres(cartres.get(position).product_id, cartres.get(position).cartproductname, cartres.get(position).cartcategoryname, cartcount, cartprice, total); } }); private void setcartprice(string pid, viewholder holder) { cursor cursor = commonutil.dbutil.getcartindividualprice(pid); if (cursor != null && cursor.movetofirst()) { int cartindividualtotal = integer.parseint(cursor.getstring(cursor.getcolumnindex(dbhelper.cart_total))); holder.cartpricedum.settext(string.valueof(cartindividualtotal)); log.e("restaurant", " adaptercheck" + cartindividualtotal + " " + holder.cartpricedum.gettext().tostring()); } }
you invalidating view. after setcartprice(pid, holder); view.invalidate();
whenever invalidate view, view start redraw including child views. may why resets default value.
Comments
Post a Comment