I am currently making an app where i have a list for request to needs to be marked as finished and another list for the items inside the request. If I select a request, the items inside it will show in the items list and buttons with actions to perform for that items. But when I choose another request and press a button, the text on the button gets cleared. I am using sdk 26 on the project. It seems that the text is not displayed but the text value is still there after I tried to see if the text value of the button is still there.
EDIT: This is the part where I initialize the views.
btnCustomerInfo = findViewById(R.id.btnCustomerInfo); btnRemoveDiscount = findViewById(R.id.btnRemoveDiscount); btnClear = findViewById(R.id.btnClear); btnPay = findViewById(R.id.btnPay); btnPrintBill = findViewById(R.id.btnPrintBill); btnUpdate = findViewById(R.id.btnUpdate);
EDIT: This is the relevant xml code.
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/btnCustomerInfo" style="@style/AppTheme.Button" android:layout_width="120dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Customer Info" /> <Button android:id="@+id/btnRemoveDiscount" style="@style/AppTheme.Button" android:layout_width="120dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Remove Discount" /> <Button android:id="@+id/btnClear" style="@style/AppTheme.Button" android:layout_width="120dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Clear" /> <Button android:id="@+id/btnPay" style="@style/AppTheme.Button" android:layout_width="120dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Pay" /> </TableRow> <TableRow android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/btnPrintBill" style="@style/AppTheme.Button" android:layout_width="120dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Print Bill" /> <Button android:id="@+id/btnTransfer" style="@style/AppTheme.Button" android:layout_width="120dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Transfer" /> <Button android:id="@+id/btnMerge" style="@style/AppTheme.Button" android:layout_width="120dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Merge" /> <Button android:id="@+id/btnUpdate" style="@style/AppTheme.Button" android:layout_width="120dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Update" /> </TableRow>
EDIT: This is my AppTheme.Button
<style name="AppTheme.Button" parent="AppTheme"> <item name="colorAccent">#ebebea</item> <item name="android:textColor">@color/black</item> </style>
I am not setting any value of button in the onClick
EDIT: Button onClicks
btnCustomerInfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "btnTxt: "+((Button) view).getText()); showCustomerInfoDlg(ip); } }); btnRemoveDiscount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { MaterialDialog.Builder mDlgBuild = new MaterialDialog.Builder(ctx); mDlgBuild.title("Discount"); mDlgBuild.content("Remove discount on " + acOr.getTableName() + " " + acOr.getTableNum() + "(" + acOr.getSessionBundle() + ")" + "?"); mDlgBuild.cancelable(false); mDlgBuild.positiveText("Ok"); mDlgBuild.negativeText("Cancel"); mDlgBuild.onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); Progress_dialog("Removing discount ..."); progressDlg.show(); } }); mDlgBuild.onNegative(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }); mDlgBuild.show(); } });
for btnTransfer:
final MaterialDialog mDlg = new MaterialDialog.Builder(MainActivity.this) .customView(R.layout.dlg_transfer_table,true) .cancelable(false) .negativeText("Cancel") .onNegative(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }).show(); TextView lblTableNum = (TextView)mDlg.findViewById(R.id.lblDlgTransferTableNumber); TextView lblCustomerName = (TextView)mDlg.findViewById(R.id.lblDlgTransferCustomerName); RecyclerView lstTable = (RecyclerView)mDlg.findViewById(R.id.lstDlgTransferTableList);
The other buttons do printing, opens a webview, remove items on the list for the items inside the request, and shows another button. Even if the buttons still doesn't have code in it, clicking it still removes the text on the buttons display.
EDIT: Gif
EDIT: this are the code of the two buttons
Pay button:
final MaterialDialog mDlg = new MaterialDialog.Builder(MainActivity.this) .title("Payment Options") .customView(R.layout.dlg_pay_option,true) .cancelable(false).show(); Button btnCash = (Button)mDlg.findViewById(R.id.btnDlgPayOptionCash); Button btnCard = (Button)mDlg.findViewById(R.id.btnDlgPayOptionCard); Button btnOther = (Button)mDlg.findViewById(R.id.btnDlgPayOptionOther); Button btnCancel = (Button)mDlg.findViewById(R.id.btnDlgPayOptionCancel); Button btnRemovePayment = (Button)mDlg.findViewById(R.id.btnDlgPayOptionRemovePayment); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mDlg.dismiss(); } }); btnCash.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mDlg.dismiss(); typeOfPayment = "cash"; CashPayment(); } }); btnCard.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mDlg.dismiss(); typeOfPayment = "card"; CardPayment(); } }); btnOther.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mDlg.dismiss(); typeOfPayment = "other"; OtherPayment(); } });
Update button:
Intent i = new Intent(MainActivity.this, UpdateOrder.class); i.putExtra("or_id", acOr.getSessionBundle()); i.putExtra("cust_name", acOr.getCustomerName()); i.putExtra("table_num", acOr.getTableNum()); startActivity(i); finish();
At first, I already selected an item on the right then clicked pay. Next, I selected another item on the right and clicked pay. Then I clicked cancel on the dialog. Lastly, I clicked the update button.
1 Answers
Answers 1
There's a good chance that the text is not cleared but has the background color in a certain state. To deal with it, you can create a color state list and set it in the android:textColor
attribute.
0 comments:
Post a Comment