Android的吐司消息不显示 [英] Android Toast Message is not showing
本文介绍了Android的吐司消息不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经Button.When用户点击按钮,也有一些条件,这个条件不符合则需要显示吐司,但不显示敬酒消息...
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:编辑
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();
}
}
}
}
}
});
我已经试过上下文的getParent()
, getApplicationContext()
, SpecialDiscountActivity。这个
&放大器; getBaseContext()
,但没有工作......
I have tried context with getParent()
, getApplicationContext()
, SpecialDiscountActivity.this
& getBaseContext()
but not working....
本吐司
消息在即将到来的设置页活动组
请人帮我。
在此先感谢
推荐答案
我不喜欢这样
Toast.makeText(SalesActivityGroup.group.getParent(), "Amount can not be
grater than invoice", Toast.LENGTH_SHORT).show();
这篇关于Android的吐司消息不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文