button - Android Menu not Showing -


i'd make menu delete option. actual delete functionality isn't made yet because @ moment can't see top bar in app.

main layout (activity_main.xml):

<?xml version="1.0" encoding="utf-8"?> <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="billy.cs436.placebadgesapp.mainactivity">      <button         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:id="@+id/newplace"         android:text="@string/newplacebutton"     /> </relativelayout> 

menu layout (main.xml):

<?xml version="1.0" encoding="utf-8"?> <menu xmlns:tools="http://schemas.android.com/tools"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:android="http://schemas.android.com/apk/res/android">     <item         android:id="@+id/deletemenu"         android:icon="@drawable/clear"         android:title="@string/deletemenu"         app:showasaction="ifroom"     /> </menu> 

main activity (mainactivity.java):

package billy.cs436.placebadgesapp;  import android.content.intent; import android.app.activity; import android.os.bundle; import android.view.view; import android.widget.button; import android.view.menu; import android.view.menuitem; import android.widget.toast;  public class mainactivity extends activity {      button newplace;     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          newplace = (button) findviewbyid(r.id.newplace);         newplace.setonclicklistener(new view.onclicklistener() {             public void onclick(view v) {                 intent intent = new intent(getapplicationcontext(), setlocation.class);                 startactivity(intent);             }         });     }      @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate main; adds items action bar if present.          getmenuinflater().inflate(r.menu.main, menu);//menu resource, menu         return true;     }     @override     public boolean onoptionsitemselected(menuitem item) {         int id = item.getitemid();         if(id == r.id.deletemenu) {         // if there no badges, toast message saying (needs implementing)             toast.maketext(this, "there no badges delete!", toast.length_short).show();         //else clear badges         } else {             toast.maketext(this, "badges cleared!", toast.length_short).show();         }         return super.onoptionsitemselected(item);         }      } 

can tell why new place button thing shows when run?

edit: @t.s has correct answer. thank you.

change class extend appcompatactivity instead of activity.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -