Ich entwickle eine Restaurant App. Hier benutze ich eine Warenkorbseite, um die Nahrungsmittel zu sehen, die der Benutzer zum Auschecken ausgewählt hat. Einkaufswagen Artikel sind aufgelistet mit RecyclerView, die + & - Taste hat, um & erhöhen die Anzahl der Produkte vor dem Checkout zu erhöhen. Mein Problem ist hier.Anonymer Fehler in TextView
Lassen Sie uns die Elemente betrachten wie wie folgt:
Result TextView
ChocoBar Rs25 - 4 + = 100 // Expected Result
Vennila Rs30 - 1 + = 30
Während Schaltfläche "+" in Chocobar
Result TextView
ChocoBar Rs25 - 5 + = 100 (set as 125 within fraction of second it is changed to 100)
Vennila Rs30 - 1 + = 30
klicken Aber wenn ich getText,
resultTextView is nothing but in code I used as holder.cartPriceDum
resultTextview.getText(). toString -> gibt 125 als ChocoBar zurück der Artikel Werte.
GetText funktioniert aber setText hat nicht funktioniert. Gettting Verwirrung. Bitte helfen Sie mir, ich habe mehr Zeit für die Reparatur aufgewendet. Trotzdem habe ich es nicht behoben.
MyCode ist wie folgt:
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 all the updated value into the 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 is 1, then 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());
}
}
Entschuldigung, das Ergebnis ist das gleiche auch nach dem Entfernen von view.invalidate(); –