Android - the following class could not be found -
i creating bottom menu in android app
i have created on directory in res/menu/option_menu.xml
this
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <item android:id="@+id/post_offer" android:title="postoffer" android:icon="@drawable/ic_launcher" tools:ignore="hardcodedtext" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <item android:id="@+id/history" android:title="history" android:icon="@drawable/ic_launcher" tools:ignore="hardcodedtext" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <item android:id="@+id/inbox" android:title="inbox" android:icon="@drawable/ic_launcher" tools:ignore="hardcodedtext" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <item android:id="@+id/notifications" android:title="notifications" android:icon="@drawable/ic_launcher" tools:ignore="hardcodedtext" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <item android:id="@+id/people" android:title="people" android:icon="@drawable/ic_launcher" tools:ignore="hardcodedtext" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </menu>
then included xml in activity_main.xml , java
<include layout="@menu/option_menu" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentbottom="true" />
and java
@override public boolean oncreateoptionsmenu(menu menu){ //menuinflater inflater = getmenuinflater(); //inflater.inflate(r.menu.option_menu, menu); //return true; getmenuinflater().inflate(r.menu.option_menu, menu); return true; } @override public boolean onoptionsitemselected(menuitem item){ switch (item.getitemid()){ case r.id.post_offer: startactivity(new intent(this, registeractivity.class)); return true; default: return super.onoptionsitemselected(item); } }
now problem when try check activity_main.xml in design mode showing following error
missing classes
the following classes not found:
-item (fix build path, edit xml)
-menu(fix build path, edit xml)
edit
i using
compile sdk version: api 25:android 7.1.1(nougat)
build tool version: 25.0.1
then included xml in activity_main.xml , java
you shouldn't that. leave menu
xml layout , inflate did in oncreateoptionsmenu()
. should work.
Comments
Post a Comment