0

Hello guys i want to display action with text and images on action bar, but i only get text in overflow menu

my menu.xml file

<?xml version="1.0" encoding="utf-8"?>
 <menu xmlns:android="http://schemas.android.com/apk/res/android">

<item
    android:id="@+id/action_show_ir_list"

    android:showAsAction="ifRoom"
    android:title="Cancel"/>


<item
    android:id="@+id/phone"
    android:title="Wowio"
    android:icon="@drawable/logo"
    android:showAsAction="ifRoom"
  />
  <!--android:icon="@drawable/info"-->

  <item
    android:id="@+id/computer"
    android:title="Done"

    android:showAsAction="ifRoom"
    />


    </menu>

in my main class

   @Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);

    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    super.onOptionsItemSelected(item);

    switch(item.getItemId()){
        case R.id.phone:
             Toast.makeText(getBaseContext(), "You selected About App", Toast.LENGTH_SHORT).show();
            break;

        case R.id.computer:


            Toast.makeText(getBaseContext(), "You selected About Developer", Toast.LENGTH_SHORT).show();
            break;
        case R.id.action_show_ir_list:

            Toast.makeText(getBaseContext(), "Volume Set To Max", Toast.LENGTH_SHORT).show();
            break;

    }
    return true;

}

Here every thing is coming in over flow menu nothing is coming on action bar enter image description here

I tried every thing on internet and nothing is working

What should i do to show them on ActionBar?

Manohar
  • 22,116
  • 9
  • 108
  • 144
  • Use custom view in toolbar check [this](http://stackoverflow.com/questions/32774757/add-custom-layout-to-toolbar) – Raghavendra Sep 10 '16 at 11:22
  • i Dont want to use Tool bar ,it is supporting in sample projects but when we integrate with mainproject it give errors – Manohar Sep 10 '16 at 11:24
  • Then check this http://stacktips.com/tutorials/android/actionbar-with-custom-view-example-in-android – Raghavendra Sep 10 '16 at 11:28

1 Answers1

0
<menu xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:[yourapp]="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/menu_add_size"
android:title="@string/menu_add_item"
android:orderInCategory="10"
[yourapp]:showAsAction="always"
android:icon="@android:drawable/ic_menu_add" />

instead of [yourapp] type your app name

Manohar
  • 22,116
  • 9
  • 108
  • 144
Androider
  • 3,833
  • 2
  • 14
  • 24