Action buttons doesn't show up on Action Bar?

Viewed 43886

I am following the tutorial on developer.android.com and trying to add items on action bar.

Although i added all the code the search action shows as an overflow element instead of an action button element. I tried on 4" and 7" virtual devices with soft keyboard option.

Here is the

main_activity_actions.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Search, should appear as action button -->
<item android:id="@+id/action_search"
    android:icon="@drawable/ic_action_search"
    android:title="@string/action_search"
    android:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="@+id/action_settings"
    android:title="@string/action_settings"
    android:showAsAction="never" />
</menu>

Here is the MainActivity.java 's onCreateOptionsMenu method.

 @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main_activity_actions, menu);
        return super.onCreateOptionsMenu(menu);
    }

enter image description here

I want to learn what causes this problem.

2 Answers
Related