android


ActionBarDrawerToggle in activity breaks options menu in fragments


I have Toolbar and DrawerLayout with NavigationView in activity, and OptionsMenu in fragments. I use ActionBarDrawerToggle with toolbar to have hamburger item:
setSupportActionBar(binding.includedAppBarLayout.toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
drawerToggle = new ActionBarDrawerToggle(this,
binding.drawerLayout,
binding.includedAppBarLayout.toolbar,
R.string.navigation_drawer_open,
R.string.navigation_drawer_close);
And after that I assign drawerToggle to drawerLayout:
binding.drawerLayout.addDrawerListener(drawerToggle);
Then, I put fragments in activity's content area below toolbar, and call setHasOptionsMenu(true) inside fragment's onCreate() method.
Fragments get their menus inflated and set up but they never get displayed on activity's toolbar.
BUT, if I remove drawerListener(drawerToggle) from drawerLayout, Options Menu works well, but no hamburger icon accordingly.
SOLUTION Actually this was my fault from the beginnig. I found that I had another Toolbar inside fragments, that's why drawerToggle wasn't working properly.

Related Links

Posting JSON to NodeJS server shows success when it is actually a failure
How can we use two different colors in hint of an Text Input Layout
GCM message is not received on broken network about 15-30 minute
Clear Intents between instrumentation tests
speedometer with custom image in android
Is it possible to specify border in android button with keeping its background?
Could not get unknown property 'repositoryUrl' for project
When and why deliverResult is called in AsyncTaskLoader?
Issue with ZBar library in Android Nogut
Cardview margin not showing correctly when using in listview
Handle exception in print class
How to evenly position buttons below the guideline in constraint layout
APK using Retrofit library crashes on start
Firebase app with reused package name records no data
Converting Facebook SDK GraphRequest object to Volley's Request object type
How to know the elapsed time for json date

Categories

HOME
algorithm
static
sh
sublimetext
newrelic
code-coverage
data-visualization
google-cloud-datalab
gluon-mobile
bing-maps
emoji
x-cart
tput
libc
bitnami
altera
parameter-passing
gruntfile
firefox-addon
intershop
symfony-console
jmp
poedit
named-entity-recognition
beta
beautifier
wcag
paperjs
mql
winpe
twiml
corenlp-server
mobx
dst
cart
deltaspike
fstream
wacom
classcastexception
android-augmented-reality
protein-database
verifiable-c
diacritics
magento-1.9.3
xv6
naming
uiimage
optimizely
puredata
chai-as-promised
vugen
pybrain
swingworker
qtplugin
jclouds
qiime
nservicebus5
dynamics-nav-2016
grgit
xvim
phonertc
rubaxa-sortable
wso2greg
botan
canvg
primitive-types
sql-scripts
genymotion-call
cbind
trdion2011
named-parameters
ora-00904
accesscontrolexception
openargs
rfc5322
mt4j
hibernate-entitymanager
scringo
node-blade
abstract-data-type
wimax
intersect
dopostback
midlet
pstack
flex-mobile
expression-blend-4
saxparseexception
tmx
nstokenfield
pagemethods
build-environment
lalr
windows-identity

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App