Options menu action bar

Can anyone understand why my help icon is not showing in the action bar? I have pasted the relevant parts of my code below

thank

menu topline.xml: `

<item
    android:id="@+id/gohome_id"
    android:title="Home"
    trial10:showAsAction="ifRoom"
    />

<item
    android:id="@+id/helpme_id"
    android:title="help"
    android:icon="@drawable/ic_questionmark"
    android:orderInCategory="200"
    trial10:showAsAction="always"
    />

      

`

styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>

<style name="CustomActionBarTheme"
    parent="@android:style/Theme.Holo.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<style name="MyActionBar"
    parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@drawable/logo3</item>
    <item name="android:icon">@drawable/leaflogo</item>

</style>
<style name="orangestyle" parent="@android:style/Theme.NoTitleBar">
    <item name="android:windowBackground">@color/orange</item>
</style>'

      

This is in my java activity:

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


@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);

    switch(item.getItemId()){
        case R.id.gohome_id:
            gohome();
            break;

    }
    return true;

}

      

finally my manifest:

  <activity
        android:name=".test1"
        android:label="Test"
        android:theme="@style/CustomActionBarTheme" >
    </activity>

      

+3


source to share


2 answers


try it



<item
    android:id="@+id/gohome_id"
    android:title="Home"
    android:showAsAction="ifRoom"
    />

<item
    android:id="@+id/helpme_id"
    android:title="help"
    android:icon="@drawable/ic_questionmark"
    android:showAsAction="always"
    />

      

+1


source


Have you put your item in a menu tag?

<menu ....>
    <item.../>
    <item.../>
</menu>

      



If so, modify trial10: showAsAction with attachment: showAsAction. Just enter if there is a bug in the app. Also remove this order line from home item

0


source







All Articles