android - No Overflow Button -
i have navigation drawer application not displaying overflow button. have checked , device not have menu button, should appear im not sure why isn't appearing. of code below
main layout
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:opendrawer="start" android:background="@color/colorprimary"> <include layout="@layout/app_bar_brgo" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.navigationview android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitssystemwindows="true" app:headerlayout="@layout/nav_header_brgo" app:menu="@menu/activity_brgo_drawer" app:itemtextcolor="@color/colorprimarydark" app:itembackground="@color/colorprimary" android:background="@color/colorprimary"/> </android.support.v4.widget.drawerlayout>
app bar
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:context="com.tble.brgo.brgo"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="wrap_content" app:theme="@style/apptheme" > <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="?attr/colorprimary" app:titletextcolor="@color/colorprimarydark" app:theme="@style/apptheme" /> </android.support.design.widget.appbarlayout> <view android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/coloraccent"/> <framelayout android:id="@+id/fragmentcontainer" android:layout_width="match_parent" android:layout_height="match_parent"> </framelayout> </linearlayout> </android.support.design.widget.coordinatorlayout>
menu
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context="com.tble.brgo.brgo"> <item android:id="@+id/s14273" android:orderincategory="100" android:title="high school" app:showasaction="never" /> <item android:id="@+id/s14276" android:orderincategory="100" android:title="middle school" app:showasaction="never" /> <item android:id="@+id/s14274" android:orderincategory="100" android:title="hillside" app:showasaction="never" /> <item android:id="@+id/s14271" android:orderincategory="100" android:title="eisenhower" app:showasaction="never" /> <item android:id="@+id/s14278" android:orderincategory="100" android:title="van holten" app:showasaction="never" /> <item android:id="@+id/s14277" android:orderincategory="100" android:title="milltown" app:showasaction="never" /> <item android:id="@+id/s14275" android:orderincategory="100" android:title="j.f.k. primary" app:showasaction="never" /> <item android:id="@+id/s14272" android:orderincategory="100" android:title="hamilton" app:showasaction="never" /> <item android:id="@+id/s14269" android:orderincategory="100" android:title="crim primary" app:showasaction="never" /> <item android:id="@+id/s14268" android:orderincategory="100" android:title="bradely gardens" app:showasaction="never" /> <item android:id="@+id/s14264" android:orderincategory="100" android:title="adamsville" app:showasaction="never" /> </menu>
main java file
package com.tble.brgo; import android.content.context; import android.content.sharedpreferences; import android.os.bundle; import android.support.design.widget.navigationview; import android.support.v4.view.gravitycompat; import android.support.v4.widget.drawerlayout; import android.support.v7.app.actionbardrawertoggle; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.view.menu; import android.view.menuitem; import android.support.v4.app.fragment; import android.support.v4.app.fragmenttransaction; import android.support.v4.app.fragmentmanager; import android.view.layoutinflater; import android.view.view; import layout.calendar; import layout.news; import layout.studentid; import layout.temp; import layout.websites; import layout.about; public class brgo extends appcompatactivity implements navigationview.onnavigationitemselectedlistener { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_brgo); news initial = new news(); fragmenttransaction transfer = getsupportfragmentmanager().begintransaction(); transfer.replace(r.id.fragmentcontainer, initial).commit(); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); actionbardrawertoggle toggle = new actionbardrawertoggle( this, drawer, toolbar, r.string.navigation_drawer_open, r.string.navigation_drawer_close); drawer.adddrawerlistener(toggle); toggle.syncstate(); navigationview navigationview = (navigationview) findviewbyid(r.id.nav_view); navigationview.setnavigationitemselectedlistener(this); navigationview.setitemtextappearance(r.style.itemfont); } @override public void onbackpressed() { drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); if (drawer.isdraweropen(gravitycompat.start)) { drawer.closedrawer(gravitycompat.start); } else { super.onbackpressed(); } } public void takepic(view v) { fragmentmanager fm = getsupportfragmentmanager(); studentid temp = (studentid) fm.findfragmentbyid(r.id.fragmentcontainer); temp.takepicture(); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.brgo, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); sharedpreferences sharedpref = getpreferences(context.mode_private); sharedpreferences.editor editor = sharedpref.edit(); //noinspection simplifiableifstatement if (id == r.id.s14273) { editor.putint("school", 14273); editor.commit(); return true; } else if(id == r.id.s14276){ editor.putint("school", 14276); editor.commit(); return true; } else if(id == r.id.s14274){ editor.putint("school", 14274); editor.commit(); return true; } else if(id == r.id.s14271){ editor.putint("school", 14271); editor.commit(); return true; } else if(id == r.id.s14278){ editor.putint("school", 14278); editor.commit(); return true; } else if(id == r.id.s14277){ editor.putint("school", 14273); editor.commit(); return true; } else if(id == r.id.s14275){ editor.putint("school", 14275); editor.commit(); return true; } else if(id == r.id.s14272){ editor.putint("school", 14272); editor.commit(); return true; } else if(id == r.id.s14269){ editor.putint("school", 14269); editor.commit(); return true; } else if(id == r.id.s14268){ editor.putint("school", 14268); editor.commit(); return true; } else if(id == r.id.s14264){ editor.putint("school", 14264); editor.commit(); return true; } return super.onoptionsitemselected(item); } @suppresswarnings("statementwithemptybody") @override public boolean onnavigationitemselected(menuitem item) { // handle navigation view item clicks here. int id = item.getitemid(); fragment fragment; switch (id) { case r.id.nav_news: fragment = news.newinstance(); break; case r.id.nav_calendar: fragment = calendar.newinstance(); break; case r.id.nav_websites: fragment = websites.newinstance(); break; case r.id.nav_about: fragment = about.newinstance(); break; default: fragment = temp.newinstance(); break; } fragmenttransaction transfer = getsupportfragmentmanager().begintransaction(); transfer.replace(r.id.fragmentcontainer,fragment).addtobackstack("tag").commit(); drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); drawer.closedrawer(gravitycompat.start); return true; } }
in oncreateoptionmenu retun :
return super.oncreateoptionsmenu(menu);
instead of return true.
Comments
Post a Comment