How to check if drop down menu of ActionBar is active
-
I'm using the ActionBar extending from the AppCompatActivity. How can I check, if the dropdown menu of the ActionBar is opened at the moment. I've tried it in this method. But it does not fire if I open the drop down menu: @Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent = new Intent(); Log.i("ActionBar", "ActionBar dropdown is open at this moment"); switch (item.getItemId()) { case R.id.preferences: intent.setClass(StartupActivity.this, PreferencesActivity.class); startActivityForResult(intent, 0); return true; case R.id.info: intent.setClass(StartupActivity.this, InformationActivity.class); startActivityForResult(intent, 0); return true; case R.id.contact: intent.setClass(StartupActivity.this, ContactActivity.class); startActivityForResult(intent, 0); return true; default: return super.onOptionsItemSelected(item); } } It only fires, if I click on an item of the drop down menu. But I want to check, if the user clicks on the three-dot menu.
-
Answer:
Try the following method: @Override public boolean onMenuOpened(int featureId, Menu menu) { // menu is open return super.onMenuOpened(featureId, menu); }
Stampy at Stack Overflow Visit the source
Other answers
I've tried this method, it works: @Override public boolean onPrepareOptionsMenu(Menu menu) { // menu open return super.onPrepareOptionsMenu(menu); } Even when initializing the menu, and not only when you click, but better than nothing.
Stampy
Related Q & A:
- How To Check Verizon Esn Online For Free?Best solution by Yahoo! Answers
- How to drag and drop a JPanel to another JPanel?Best solution by stackoverflow.com
- How to make a drop-in ramp for snowboarding?Best solution by Yahoo! Answers
- How To Check How Many People Visited My Website?Best solution by Yahoo! Answers
- How to become a drop shipper?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.