Unable to display Toast from Activity except my main action

I have an Activity main. If i call

Toast.makeText(this, "Hello World from main", Toast.LENGTH_SHORT); 

this works great. However, for every other action in my application, I cannot display Toast. No exception, nothing in the magazine, but I do not see Toast.

My main activity begins with another menu with options:

 @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.main_menu_entry: Intent infolist = new Intent(this, infolist.class); startActivityForResult(infolist, R.layout.infolist); return true; default: return super.onOptionsItemSelected(item); } } 

In my infolist activity, I have another options menu that Toast should display.

 @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.infolist_menu_entry: // this Toast is never shown. Toast.makeText(this, "Hello World from infolist", Toast.LENGTH_Short); return true; default: return super.onOptionsItemSelected(item); } } 

Any ideas what might cause this problem? I am using the latest SDK with Min SDK Version = 3 and 1.5 emulator.

+3
java android android-activity toast
source share
2 answers

I would say a classic mistake:
You forgot the Toast.show() ;) method

+9
source share

At the end, you will skip the show() method.

 Toast.makeText(this, "Hello World from infolist", Toast.LENGTH_Short).show(); 
0
source share

All Articles