Navigation Drawer listview not refreshing listitems

后端 未结 1 712
陌清茗
陌清茗 2021-01-20 15:26

I am creating one app,and i am using NavigationDrawer and Fragments in my application,now issue is I have five ListItems in Navi

相关标签:
1条回答
  • 2021-01-20 16:31

    You shouldn't try to hide the drawer items. I would just update the adapter, remove the items you don't need and then invalidate it.

    When the user clicks on Signout, I would just do something like this:

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        // display view for selected nav drawer item
        displayView(position);
    
        // if using fixed positions
        if(position == 6) { // position of Sign out button
    
            navDrawerItems.clear(); // empty the adapter array
            navDrawerItems.add(new NavDrawerItem(navMenuTitles[signoutIndex], navMenuIcons.getResourceId(signoutIndex, -1));
            adapter.notifyDataSetChanged();
    
        }
    }
    
    0 讨论(0)
提交回复
热议问题