That's my code:
public void loadNavigationDrawerItems(){
adapter.notifyDataSetChanged();
adapter.setItems();
//Log.d(TAG, "--> Reload Navigation Drawer");
}
is it correct? or is it better to mod it as this
public void loadNavigationDrawerItems(){
adapter.setItems();
adapter.notifyDataSetChanged();
//Log.d(TAG, "--> Reload Navigation Drawer");
}
setItems is a method of the adapter that can load item in the adapter from an external class... My question is if is better to call the notifyDataSetChanged before or after the setItems. Thanks
After. You call it when the changes have finished happening and not before hand. I'm guessing you are using a custom adapter. So ideally, the setItems()
method should be invoking notifyDataSetChanged()
itself instead of having to rely on it happening externally.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.