I have Button.When the user click the button, there are some condition, that condition is not satisfy then need to display Toast but not showing Toast Message...
Code: Edited
Button addMe = (Button)findViewById(R.id.addMe); addMe.setOnClickListener(new OnClickListener() { public void onClick(View v) { if(selectedReason.equals("--Select--")){ Log.i("TAG","-----"); Toast.makeText(getBaseContext(), "Reason can not be blank", Toast.LENGTH_SHORT).show(); }else if(selectedType.equals("--Select--")){ Toast.makeText(getParent(), "Discount type can not be blank", Toast.LENGTH_SHORT).show(); }else{ if(selectedType.equals("Value")){ if(spc_amount.getText().toString().equals("")){ Log.i("TAG","-----"); Toast.makeText(getBaseContext(), "Discount type can not be blank", Toast.LENGTH_SHORT).show(); }else{ if(Double.parseDouble(spc_amount.getText().toString()) > invoiceValue){ Toast.makeText(getBaseContext(), "Amonut can not be grater than invoice", Toast.LENGTH_SHORT).show(); }else{ Discount dis = new Discount(); dis.setCriteriaName(selectedReason); dis.setDiscountValue(Double.parseDouble(spc_amount.getText().toString())); spDisList.put(1,dis); tl.removeAllViews(); loadTableLayout(); } } } } } });
I have tried context with getParent()
, getApplicationContext()
, SpecialDiscountActivity.this
& getBaseContext()
but not working....
This Toast
message coming under the Tab Activity Group
Make sure not to forget to call show() after the makeText. Check for the Context , if its the right one. The most important one , make sure your Android Notifications are on for your app, else the Toast will not be shown.
Display the created Toast Message using the show() method of the Toast class. The code to show the Toast message: Toast. makeText(getApplicationContext(), "This a toast message", Toast.
If a toast message is not getting displayed when you run your android Application, 1. Check that you have used . show() method on the toast object as an initial troubleshooting step.
Try:
Toast.makeText(getBaseContext(), "Reason can not be blank", Toast.LENGTH_SHORT).show();
It's the .show() that you've omitted everywhere that causes all your toasts to instatiate, but never execute.
Please excuse me if this isn't the solution to your problem, but I accidentally unchecked the 'Show notification' setting of the application once. It may be an idea go into your device settings/application/manager and check this setting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With