My application implements a navigation drawer to change fragments. What I need now is to update the navigation drawer items if the user is logged in
For example : logged in navigation items look like this
Home My Info Logout
logged off navigation items look like this
Home Register Login
The set up of my project is a Base activity which extends Navigation fragment and changes to a current fragment based on the selected navigation drawer item.
All my other files are fragments which change depending on the navigation drawer item selected.
I have this kind of working but navgation drawer only updates when I log in then close the app completely and then re start it.
Your Activity must be aware of your drawer's ListView. So when you log in, you just need to tell your Activity to tell your ListView that the data has changed, or reload it completely.
In your fragment (or wherever you actually log in):
public void logIn() {
...
((DrawerActivity) getActivity()).updateDrawer();
}
In your DrawerActivity
:
public void updateDrawer() {
mListViewAdapter.notifyDataSetChanged();
// OR
mListView.setAdapter(new AdapterShowingTheRightTitles());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With