0

I wondered why i am unable to add icons in option menu. I am developing app in android 4.2 and i want to add custom menu options. I'm doing like below: In menu folder -> home_activity.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:id="@+id/about_us"
    android:title="@string/HomeActivity_aboutUs_item"
    android:orderInCategory="100"
    android:icon="@drawable/apply_img"

/>
<item
    android:id="@+id/help"
    android:title="@string/HomeActivity_help_item"
    android:icon="@drawable/browsefile"
    android:orderInCategory="102"

/>

In home_activity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.home_activity, menu);
    return true;
}

    @Override
public boolean onOptionsItemSelected(MenuItem item) {
    Resources resources = getResources();
    switch(item.getItemId()) {
        case R.id.about_us:


            return true;
        case R.id.help:

            return true;
        default :
            return super.onOptionsItemSelected(item);
    }
}

And in home_activity.xml

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".HomeActivity" >
<TextView
    android:id="@+id/HomeActivity_TextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="50dp"
    android:text="@string/HomeActivity_TextView_text"
    android:textStyle="bold"
    android:textSize="18sp" /> </RelativeLayout>
OnkarDhane
  • 1,450
  • 2
  • 14
  • 24
  • The options menu that can be accessed through the hardware menu button does not support icons anymore in Jelly Bean. Maybe already since Ice Cream Sandwich. – tiguchi Oct 06 '13 at 15:18
  • Oh. That's really sad. So It would be only plane menu options with white background., is it? – OnkarDhane Oct 06 '13 at 15:20
  • Depending on the current theme, yes. I also never understood Google's design decision to get rid of icons. Apparently they wanted to promote the use of the ActionBar and its menu buttons by making the standard menu unattractive. – tiguchi Oct 06 '13 at 15:28

0 Answers0