Action bar does not display action items (all in overflow) Android

I cannot get the action bar to display my actions. All of them are displayed in the overflow menu. I have inserted all the relevant codes below. Can anyone see my problem?

From action:

public boolean onCreateOptionsMenu(Menu menu) { MenuInflater mi = getMenuInflater(); mi.inflate(R.menu.viewer_menu, menu); return true; } @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { switch (item.getItemId()) { case R.id.menu_download: return true; case R.id.menu_star: return true; case R.id.menu_report: return true; case android.R.id.home: // app icon in action bar clicked; go home finish(); return true; } return false; } 

From the manifest:

 <activity android:name=".CustomActivity" android:label=""> 

From the values ​​folder-v11 (themes.xml)

 <resources> <style name="MyTheme" parent="@android:style/Theme.Holo"> </style> 

from the menu folder (viewer_menu.xml)

 <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_download" android:title="Download" showAsAction="withText" android:orderInCategory="2"/> <item android:id="@+id/menu_star" android:icon="@android:drawable/ic_menu_upload" android:title="Star" showAsAction="always" android:orderInCategory="1"/> <item android:id="@+id/menu_report" android:title="Report Problem" showAsAction="always" android:orderInCategory="0"/> </menu> 
+6
source share
3 answers

This is android:showAsAction , not just showAsAction .

+5
source

If you are using a support package ( android.support.v7.app.ActionBarActivity ), you should use something like this:

 <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/menu_download" android:title="Download" app:showAsAction="withText" android:orderInCategory="2"/> <item android:id="@+id/menu_star" android:icon="@android:drawable/ic_menu_upload" android:title="Star" app:showAsAction="always" android:orderInCategory="1"/> <item android:id="@+id/menu_report" android:title="Report Problem" app:showAsAction="always" android:orderInCategory="0"/> </menu> 
+4
source

Which version is your Android emulator?

Also, have you tried http://actionbarsherlock.com/ yet?

+1
source

Source: https://habr.com/ru/post/912133/


All Articles