0

I want the menu items to show on action bar. There is a lot of space on the ActionBar, but still they don't show up. Every item shown as three dots, why?

.java file

public class GalleryActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gallery_layout); } public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); return true; } } 

.xml file

 <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:MissionAndroid="http://schemas.android.com/tools"> <item android:id="@+id/facebookId" android:title="facebook" android:icon="@drawable/facebook" MissionAndroid:showAsAction="always"/> <item android:id="@+id/shareId" android:title="share" android:icon="@drawable/share" MissionAndroid:showAsAction="always"/> <item android:id="@+id/delete" android:title="delete" android:icon="@drawable/delete" MissionAndroid:showAsAction="always"/> <item android:id="@+id/searchId" android:title="search" android:icon="@drawable/search" MissionAndroid:showAsAction="ifRoom"/> </menu> 

1 Answer 1

2

Currently, you're using "http://schemas.android.com/tools" which does not offer the functionality you're looking for and your showAsAction modifiers are being ignored.

Try updating your main_menu.xml with the following:

<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:MissionAndroid="http://schemas.android.com/apk/res-auto"> ... </menu> 

Better yet, to follow convention, replace MissionAndroid in this file with app:

<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/facebookId" android:title="facebook" android:icon="@drawable/facebook" app:showAsAction="always"/> ... </menu> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.