I'm using ActionBarCompat in my app, an I want to show one or two items in the action bar
I follwed the guide of google developers, but when I test it, the items are showed in the "Overflow" option (in Nexus 4) and if I tap on the menu button if there exist (ex. Galaxy S3)
What I've doing wrong?
SOLUTION FOUND
You can find it in a answer.
I had the same problem, and found two solutions:
In the menu xml (Login.xml), use your app name for the showAsAction tag:
instead of:
<item
android:id="@+id/action_register"
android:showAsAction="always"
android:icon="@drawable/some_icon"
android:title="@string/login_menu_register" />
use:
<item
android:id="@+id/action_register"
yourappname:showAsAction="always"
android:icon="@drawable/some_icon"
android:title="@string/login_menu_register" />
I suppose your application's name is shady.
the second solution for me, on the activity class, at the onCreateOptionsMenu()
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(
getMenuInflater().inflate(R.menu.main, menu);
MenuItem registerMenuItem = menu.findItem(R.id.action_register);
registerMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); // change this in backcompat
return true;
}
if you are using backCompatibility, change last line:
MenuItemCompat.setShowAsAction(registerMenuItem,MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With