JFF*_*FFF 3 android toast android-activity
在我的Android应用程序中,我有一个按钮,导致一个活动,在某些情况下,由于if语句不启动.
会发生什么,是我.finish();在onCreate上杀死了活动,所以当用户点击按钮时没有任何反应.
但我想在当前活动中向用户显示警报,Toast.不确定这是否真的很清楚,但这应该是基本上应该发生的事情:
.finish();onCreate上的活动被杀死了.到目前为止,这是我的代码:
try {
this.storeMarkerList = new StoreMarkerList(this.mapView);
StoreList list = (StoreList)getBaseApplication().getSessionParameter("selected.storelist", null);
if (list == null || list.size() == 0){
Toast.makeText(???, "No stores", 5000);
this.finish();
}
else {
Run Code Online (Sandbox Code Playgroud)
(......)
Joe*_*Joe 13
试试这个:
Toast.makeText(getApplicationContext(), "No stores", 5000).show();
Run Code Online (Sandbox Code Playgroud)