Refresh NavigationView menu after change locale - android

I'm changing locale programmatically from fragment and everything ok. There is one exception, the NavigationView menu, where language didn't changing. How to refresh it without recreate all activity.
Mainactivity code
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = this;
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
navigationView.setEnabled(false);
DrawerLayout mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
}
R.layout.activity_main
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<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">
<include layout="#layout/app_bar_main" 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_main" app:menu="#menu/activity_main_drawer"/>
</android.support.v4.widget.DrawerLayout>
fragment code after choose locale
LocaleHelper.setLocale(getActivity(), getResources().getStringArray(R.array.locale)[locale]);
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.detach(this).attach(this).commit();
<group android:checkableBehavior="single">
<item android:id="#+id/nav_contacts" android:icon="#drawable/ic_people_black_24dp"
android:title="#string/contacts" android:checked="true"/>
<item android:id="#+id/nav_invoices" android:icon="#drawable/ic_swap_horiz_black_24dp"
android:title="#string/invoices" />
<item android:id="#+id/nav_payments" android:icon="#drawable/ic_payment_black_24dp"
android:title="#string/payments" />
<item android:id="#+id/nav_history" android:icon="#drawable/ic_receipt_black_24dp"
android:title="#string/history" />
<item android:id="#+id/nav_settings" android:icon="#drawable/ic_settings_black_24dp"
android:title="#string/settings" />
<item android:id="#+id/nav_info"
android:title="#string/info" android:icon="#android:drawable/ic_dialog_info"/>
</group>
Thanx

I've decided this problem
private void refreshNavigationView(){
getActivity().setContentView(R.layout.activity_main);
NavigationView navigationView = (NavigationView) getActivity().findViewById(R.id.nav_view);
}
That's enought for refresh NavigationView after change locale
But I lose onNavigationItemSelected
As a result at Mainactivity
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the locale has changed
if (!currentLocale.equals(newConfig.locale)) {
currentLocale = newConfig.locale;
this.setContentView(R.layout.activity_main);
NavigationView navigationView = (NavigationView) this.findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(MainActivity.this);
}
}
At fragment
getActivity().onConfigurationChanged(getActivity().getResources().getConfiguration());

You can try below code. I haven't tested it but I hope it will work.
for (int i = 0, count = navigationView.getChildCount(); i < count; i++) {
final View child = navigationView.getChildAt(i);
if (child != null && child instanceof ListView) {
final ListView menuView = (ListView) child;
final HeaderViewListAdapter adapter = (HeaderViewListAdapter) menuView.getAdapter();
final BaseAdapter wrapped = (BaseAdapter) adapter.getWrappedAdapter();
wrapped.notifyDataSetChanged();
}
}

latest solution in kotlin:
upgrade your appcompat version to 1.6.0 or later
implementation 'androidx.appcompat:appcompat:1.6.0'
create a function
fun setLocale(language: String?) {
val appLocale: LocaleListCompat = LocaleListCompat.forLanguageTags(language)
AppCompatDelegate.setApplicationLocales(appLocale)
}
then use it like
setLocale("en-EN")
it will update and refresh all language change/locale including NavigationView

Related

Always getting the error messsage: No drawer view found with gravity LEFT

I'm working on an app but I have some troubles with drawer layout. I always getting the error message like I mentioned in the title but I have no such Gravity with LEFT value. All I have are gravities with END values and that's all.
Here is my Java code:
public class HomeActivity extends AppCompatActivity {
private ActionBarDrawerToggle toggle;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Toolbar mainToolBar =findViewById(R.id.main_page_toolbar);
DrawerLayout mainDrawerLayout = findViewById(R.id.main_page_drawer_layout);
NavigationView mainNavigationView = findViewById(R.id.main_page_navigation_view);
setSupportActionBar(mainToolBar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setHomeButtonEnabled(true);
toggle = new ActionBarDrawerToggle(this,mainDrawerLayout,mainToolBar,R.string.openDrawer,R.string.closeDrawer);
mainDrawerLayout.addDrawerListener(toggle);
toggle.syncState();
}
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
toggle.onConfigurationChanged(newConfig);
}
}
And here is my XML code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.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:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="end"
tools:context=".Activities.HomeActivity"
android:id="#+id/main_page_drawer_layout"
android:fitsSystemWindows="true">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/home_main_page"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
app:headerLayout="#layout/home_side_menu_header_layout"
app:menu="#menu/home_side_menu"
android:layoutDirection="rtl"
android:id="#+id/main_page_navigation_view"/>
You need to handle navigation click on Toolbar like below:
mainToolBar.setNavigationOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (mainDrawerLayout.isDrawerOpen(GravityCompat.END))
mainDrawerLayout.closeDrawer(GravityCompat.END);
else
mainDrawerLayout.openDrawer(GravityCompat.END);
}
});
Also don't forgot to close drawer whenever needed like below:
mainDrawerLayout.closeDrawer(GravityCompat.END)

(Android) onNavigationItemSelected method not being called

I'm working on an Android app for an Engineering Design project that includes a drawer. One of my group members elected to use the android.support.design.widget.NavigationView API to do this, and it's been causing us some problems. Our MainActivity class implements onNavigationItemSelectedListener, which I understand acts as a listener for the items in the drawer and other navigation bars. The problem is, when one of these navigation items is selected, the onNavigationItemSelected method that has been implemented is not called (I know this because it's supposed to put out a message through LogCat if it is called). All the references I've found for this API suggest that I've done everything right so far, but I've apparently missed something, so any help is appreciated.
Here is the relevant code from the MainActivity class:
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setUpNavComponents();
setUpMapComponents();
PathfinderDataHandler handler = new PathfinderDataHandler();
}
private void setUpNavComponents()
{
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
navigationView.setNavigationItemSelectedListener(this);
}
private void setUpMapComponents()
{
mapFrag = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
mapFrag.getMapAsync(this);
}
#Override
public boolean onNavigationItemSelected(MenuItem item)
{
// Handle navigation view item clicks here.
int id = item.getItemId();
Log.d(null, "onNavigationItemSelected Called");
if (id == R.id.buildings)
{
// Handle the camera action
Log.d(null, "Buildings selected");
}
else if (id == R.id.blue_phones)
{
Log.d(null, "Blue Phones selected");
}
else if (id == R.id.bus_stops)
{
Log.d(null, "Bus Stops selected");
}
else if (id == R.id.pedways)
{
Log.d(null, "Pedways selected");
}
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
Here is the code from activity_main_drawer.xml (Which holds all the items for the drawer)
<?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:showIn="navigation_view">
<group
android:checkableBehavior="all"
android:enabled="true">
<item
android:id="#+id/buildings"
android:title="#string/building_show_select"
app:actionLayout="#layout/switch_item"
app:showAsAction="always" />
<item
android:id="#+id/blue_phones"
android:title="#string/blue_phone_select"
app:actionLayout="#layout/switch_item"
app:showAsAction="always" />
<item
android:id="#+id/bus_stops"
android:title="#string/bus_stop_select"
app:actionLayout="#layout/switch_item"
app:showAsAction="always" />
<item
android:id="#+id/pedways"
android:title="#string/pedway_select"
app:actionLayout="#layout/switch_item"
app:showAsAction="always" />
</group>
Here is the code for activity_main.xml, which adds the activity_main_drawer to the NavigationView.
<?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">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" />
<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_main"
app:menu="#menu/activity_main_drawer">
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
Another thing to note is that I'm using Switch items instead of regular Menu items.
And before anyone says anything, YES I know this API is depreciated and I should be using NavigationUI in AndroidX, but I don't have time to refactor the app so I have to make do with this.
You have to provide a non null tag for Log.d(String, String), else there will be nothing written to Logcat.
I tried with
Log.d(null, "HelloWorld");
Log.d("TEST", " HelloWorld");
and got only one line in Logcat:

android - my SwitchCompat cannot be cast to SwitchCompat

I'm quite new to android and AndroidStudio, and I'm having a problem with a SwitchCompat.
I need it to be on my NavigationDrawer menu, and I just want to check its isChecked value.
After some tutorials I managed to put this code together:
this is my SwitchCompat XML, drawer_switch.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.SwitchCompat
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_switch"
android:layout_width="fill_parent"
android:layout_height="match_parent"
app:showText="false" />
Then I have the NavigationView in my DrawerLayout activity_main.xml
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/nav_header"
app:menu="#menu/drawer_menu" />
and my drawer_menu.xml with its SwitchCompat
<?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:showIn="navigation_view">
<item android:title="Sondaggi"
android:id="#+id/menuSondaggi">
<menu>
<item
android:id="#+id/set_votato"
android:icon="#drawable/ic_set_votato"
android:title="Mostra giĆ  votati"
app:actionLayout="#layout/drawer_switch" />
[...]
</menu>
</item>
</menu>
Now, in my MainActivity, at the OnCreate, i'm trying to get the SwitchCompat in order to check its isChecked:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
try {
MenuItem item = (MenuItem) navigationView.getMenu().findItem(R.id.set_votato);
SwitchCompat votatoSwitch = (SwitchCompat) item;
votatoSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
votato=isChecked;
}
});
}catch (Exception e){
e.getCause();
}
[...]
}
But it gets stuck when it tries to cast item to a SwitchCompat, saying java.lang.ClassCastException: android.support.v7.view.menu.MenuItemImpl cannot be cast to android.support.v7.widget.SwitchCompat. The fact is that if I debug, I can see that the item knows to be a SwitchCompat, as you can see from the image: Debug screenshot
Where's my mistake?
Than you in advance.
item is a MenuItem. The View class doesn't extend the MenuItem class, so you can't cast it to a View.
I think you want the MenuItem#getActionView() method. This returns the inflated layout you set in android:actionLayout.
SwitchCompat votatoSwitch = (SwitchCompat) item.getActionView();
The set_votato is a MenuItem you should try item.getActionView() and cast that to a switchCompat

How to add navigation drawer in MainActivity Tab Layout?

Please teach me how to add navigation drawer in this activity.
MainActivity (Tab Layout)
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
assert tabLayout != null;
tabLayout.addTab(tabLayout.newTab().setText(R.string.welcome));
tabLayout.addTab(tabLayout.newTab().setText(R.string.venue));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
final PagerAdapter adapter = new FragmentStatePagerAdapter(getSupportFragmentManager()) {
#Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return new WelcomeFragment();
case 1:
return new pptp();
}
return null;
}
#Override
public int getCount() {
return 2;
}
};
assert viewPager != null;
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
#Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
#Override
public void onTabUnselected(TabLayout.Tab tab) {
}
#Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
public void refreshNow() {
finish();
overridePendingTransition(0,0);
startActivity(getIntent());
overridePendingTransition(0,0);
}
}
Teach me how to add navigation drawer it will helps me a lot.
Thank you in advance for those who willing to help me.
add the following dependencies to your apps module's build.gradle file:
dependencies {
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
}
Inside the DrawerLayout, add a layout for the main content for the UI (your primary layout when the drawer is hidden) and another view that contains the contents of the navigation drawer.
For example, the following layout uses a DrawerLayout with two child views: a FrameLayout to contain the main content (which could, for example, by populated by a Fragment at runtime), and a NavigationView for the contents of the navigation drawer.
<?xml version="1.0" encoding="utf-8"?>
<!-- Use DrawerLayout as root container for activity -->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- Layout to contain contents of main body of screen (drawer will slide over this) -->
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<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" />
</android.support.v4.widget.DrawerLayout>
To configure the menu items listed in the drawer, specify a menu resource with the app:menu attribute, as shown in the example code below:
<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:menu="#menu/drawer_view" />
Create the menu resource with the corresponding file name. For example, at res/menu/drawer_view.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_camera"
android:icon="#drawable/ic_menu_camera"
android:title="#string/import" />
<item
android:id="#+id/nav_gallery"
android:icon="#drawable/ic_menu_gallery"
android:title="#string/gallery" />
<item
android:id="#+id/nav_slideshow"
android:icon="#drawable/ic_menu_slideshow"
android:title="#string/slideshow" />
<item
android:id="#+id/nav_manage"
android:icon="#drawable/ic_menu_manage"
android:title="#string/tools" />
</group>
</menu>

onNavigationItemSelected not being called [duplicate]

I am trying to use NavigationView from Android Support Design library in my app. For some reason, OnNavigationItemSelected listener is not being called. Here is my code
Activity 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"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/drawer_header"
app:menu="#menu/drawer_menu" />
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.DrawerLayout>
Activity onCreate()
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutID());
toolbar = (Toolbar) findViewById(R.id.activity_toolbar);
setSupportActionBar(toolbar);
toolbar.inflateMenu(R.menu.common_menu);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
actionBar.setDisplayHomeAsUpEnabled(true);
}
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
navigationView = (NavigationView) findViewById(R.id.navigation_view);
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
#Override
public boolean onNavigationItemSelected(final MenuItem menuItem) {
Snackbar.make(contentLayout, menuItem.getTitle() + " pressed", Snackbar.LENGTH_LONG).show();
menuItem.setChecked(true);
// allow some time after closing the drawer before performing real navigation
// so the user can see what is happening
drawerLayout.closeDrawer(GravityCompat.START);
mDrawerActionHandler.postDelayed(new Runnable() {
#Override
public void run() {
navigate(menuItem.getItemId());
}
}, DRAWER_CLOSE_DELAY_MS);
drawerLayout.closeDrawers();
return true;
}
});
usernameTextView = (TextView) findViewById(R.id.drawer_header_username);
usernameTextView.setText(getAppDContext().getAccount().getUsername());
}
When you make XML layout, you should write down NavigationView after BaseLayout (FrameLayout, LinearLayout, etc..)
<DrawerLayout>
<FrameLayout />
<NavigationView />
</DrawerLayout>
For me this did the trick!
navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.bringToFront();
Your activity main layout should look like this:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/navigationDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/activity_main_content" />
<android.support.design.widget.NavigationView
android:id="#+id/navigationView"
style="#style/NavigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
app:headerLayout="#layout/header"
app:menu="#menu/menu_drawer"/>
</android.support.v4.widget.DrawerLayout>
In this NavigationView I linked header.xml and menu_drawer.xml (from menu folder)
for example menu_drawer.xml :
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="#+id/nav1"
android:checked="true"
android:icon="#drawable/logo"
android:title="Navigation item 1"/>
<item
android:id="#+id/nav2"
android:icon="#drawable/logo"
android:title="Navigation item 2"/>
</group>
</menu>
than your java code:
public class ActivityMain extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setUpToolbar();
setUpNavDrawer();
}
private void setUpNavDrawer() {
NavigationView view = (NavigationView) findViewById(R.id.navigationView);
mDrawerLayout = (DrawerLayout) findViewById(R.id.navigationDrawer);
view.setNavigationItemSelectedListener(this);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawerOpen, R.string.drawerClose);
mDrawerLayout.addDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
}
Check if this work for you. In my project works like a charm.

Categories

Resources