Not able to set icons in Android 4.2.2 option menu -
i wondered why unable add icons in option menu. developing app in android 4.2 , want add custom menu options. i'm doing 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 menu; adds items action bar if 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>
Comments
Post a Comment