简体   繁体   中英

Toast displayed in HTC Nexus One and not working with Samsung Fame

I try to display a Toast.

Toast.makeText(this, "HOLA", Toast.LENGTH_LONG).show();

And it doesn't appear... Even if I put it just after onCreate(), on the almost first instruction......

I call it in the mainActivity. It was working before in my app....

EDIT: It seems that in another phone, toast are displaying well, But I can't get it work anyway. It is working with a HTC Nexus One ( API 10), but won't work with a Samsung Fame ( API 14)

尝试在这样的上下文中使用活动名称

Toast.makeText(ActivityName.this, "HOLA", Toast.LENGTH_LONG).show();

Try using Activity Name in context like this

Toast.makeText(ActivityName.this, "HOLA", Toast.LENGTH_LONG).show();

Or

Toast.makeText(getApplicationContext(), "HOLA", Toast.LENGTH_LONG).show();

or

Toast.makeText(getBaseContext(), "HOLA", Toast.LENGTH_LONG).show();

Or

Toast.makeText(getActivity(), "HOLA", Toast.LENGTH_LONG).show();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM