Action bar item is not coming in Action bar

101 views Asked by At

I am trying to add a single item in my action bar. But even though I am using showAction="always" Still I am not able to see the icon in my action bar. Instead it is getting displayed once I click on Menu button. Can someone point out what I am missing. I am following this tutorial : https://developer.android.com/training/basics/actionbar/adding-buttons.html

2

There are 2 answers

0
Rahul Aggarwal On

The menu will be shown on action bar depends on your mobile. When you use mobile without menu option or alter simply add uiOptions="splitActionBarWhenNarrow" to your manifest element.

4
Kavin Prabhu On

I think your class is extending ActionBarActivity instead extend your class to Activity. This is because for backward compatibility for older version of Android.

Edit

Check whether you have a class like below:

@override
class MainActivity extends ActionBarActivity {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

Then change it to like this and try:

@override
class MainActivity extends Activity {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

Hope this is the issue. If it didn't work let me know!