Hello
I'm trying to add 2 menu items in the action bar. On the designer they look ok, but when I run the application, both menu items goes in the dropdown list hamburger menu (there's enough "room" to display on the action bar).
I tried to replace app:showAsAction
to android:showAsAction
, doesn't work this replacement.
this is my menu_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.tabdemo.MainActivity">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title=""
app:showAsAction="never"
/>
<item
android:id="@+id/userMenu"
android:title="User"
app:showAsAction="ifRoom" />
<item
android:id="@+id/logoutMenu"
android:icon="@drawable/opendoorlogo2"
android:title="Logout"
app:showAsAction="ifRoom" />
And this is the java code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
MenuItem userMenuItem = menu.findItem(R.id.userMenu);
userMenuItem.setTitle(username);// global string
MenuItem logoutMenuItem = menu.findItem(R.id.logoutMenu);
logoutMenuItem.setIcon(R.drawable.opendoorlogo2);
return true;
}
Thanks in advance (P.S. Logo doesn't load on Logout menu Item)