Android Action Bar won't show items -


i cannot icons show in action bar.

i using recent sdk eclipse.

i trying tutorial http://developer.android.com/training/basics/actionbar/adding-buttons.html

my mainactivity.java

package com.example.myfirstapp;  import android.os.bundle; import android.app.activity; import android.support.v7.app.actionbaractivity; import android.view.menu; import android.view.menuinflater;  public class mainactivity extends actionbaractivity   {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);     }    @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu items use in action bar         menuinflater inflater = getmenuinflater();         inflater.inflate(r.menu.main, menu);         return super.oncreateoptionsmenu(menu);     }     } 

my main.xml under menu is

<menu xmlns:android="http://schemas.android.com/apk/res/android" >     <item android:id="@+id/action_search"           android:icon="@drawable/ic_action_search"           android:title="@string/action_search"           android:showasaction="always" />     <item android:id="@+id/action_settings"           android:title="@string/action_settings"           android:showasaction="always" >     </item>  </menu> 

but dont see menu items. looks menu missing items on how these menu items shows useful.

thank you.

quoting docs:

the showasaction attribute above uses custom namespace defined in tag. necessary when using xml attributes defined support library, because these attributes not exist in android framework on older devices. must use own namespace prefix attributes defined support library.

so following modifications:

<menu xmlns:android="http://schemas.android.com/apk/res/android"       xmlns:yourapp="http://schemas.android.com/apk/res-auto" >     <item android:id="@+id/action_search"           android:icon="@drawable/ic_action_search"           android:title="@string/action_search"           yourapp:showasaction="always" />     <item android:id="@+id/action_settings"           android:title="@string/action_settings"           yourapp:showasaction="always" >     </item> </menu> 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -