0
votes

i cannot seem to make the icons appear on the action bar on top of the activity at my project, i am using the right namespace with the right extend and everything should be running be smoothly, this is the xml for the menu items and i have added the line "xmlns:app="http://schemas.android.com/apk/res-auto"" and it still doesn't work

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_search"
    android:icon="@mipmap/ic_search_white_24dp"
    android:title="Search"
    android:showAsAction="ifRoom"/>
<item android:id="@+id/action_add"
    android:icon="@mipmap/ic_add_white_48dp"
    android:title="Add"
    android:showAsAction="ifRoom"/>

this is the java code for the menu inflater

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_actions, menu);
    return super.onCreateOptionsMenu(menu);
}
2
Do you call the menu xml in your android activity?makis kontis
yes i just updated my question to add the activity partuser6677716
Is the menu showing, in other words is the drop down menu showing? ifRoom is a bit finicky, if you want the icons to show try switching the showAsAction value to alwaysChris Stillwell
yes when i click on the 3 dots the menu still works and everything is working perfectly fine, but the icons will never show, i even tried the value to always and still nothinguser6677716
This might have to do with using mipmaps, try changing your icons to be in the drawable folder. See this question for more info: stackoverflow.com/questions/34867315/…Chris Stillwell

2 Answers

1
votes

i found the solution to my problem. since i have been trying to use namespace

xmlns:app="http://schemas.android.com/apk/res-auto"

then i should use

app:showAsAction="ifRoom" 

instead of

android:showAsAction="ifRoom"
0
votes

You have to inflate your menu using

getMenuInflater().inflate(R.menu.main, menu);

When you call onCreateOptionsMenu

Also try to add order attribute in your xml