Dropdown-free Action Bar menu icon

Asked

Viewed 151 times

2

I’m trying to remove the dropdown menu from the Actionbutton Overflow from the Action Bar. In this case it would be the one that has the 3 points, one on top of the other, as default and as default option, "Settings". I would like to remove this "Settings" item, causing it to already perform an action by clicking on the menu icon. Any ideas ?

  • How is your xml menu file? You used the attribute showAsAction="always"?

  • Yeah, it’s like "Always".

1 answer

1

In the.xml menu you create the option

<item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:icon="@android:drawable/ic_settings"
        app:showAsAction="always"
        android:title="settings" />

And then go to your Activity and

public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if(id == R.id.action_settings) {
                Intent intent = new Intent(this, SettingsActivity.class);
                startActivity(intent);
                return true;
        }
       return super.onOptionsItemSelected(item);
}

I implemented something like this in my app and it worked, I hope it works for you.

  • Very good Kamila Brito, would be a solution to open a new screen (settings)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.