1

What is the listener for click event of overflow icon in action bar?

It is not detected in the onoptions selected so where else it can be detected

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    Log.e("id  ", ""+id);

    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}
3

1 Answer 1

1

There is no onClick Listener for the overflow menu itself; only for items inside the menu. When you click on an element inside the overflow menu, onOptionsItemSelected() is called.

Sign up to request clarification or add additional context in comments.

1 Comment

@Override public boolean onMenuOpened(int featureId, Menu menu) { if(featureId == AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR && menu != null){ //overflow menu clicked, put code here... } return super.onMenuOpened(featureId, menu); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.