Refresh Header in Navigation Drawer

后端 未结 1 1059
天涯浪人
天涯浪人 2020-12-07 03:11

Though i have been looking around, couldn\'t find the correct answer. In my navigation drawer header I provide user with his image and name, But i also allow the user to cha

相关标签:
1条回答
  • 2020-12-07 04:05

    Though I am really sorry for posting the answer this late. I resolved my problem by refreshing the header whenever I open the drawer or we can when onDrawerOpened is called.

        mDrawerToggle = new ActionBarDrawerToggle(Homepageactivity.this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {
    
            /** Called when a drawer has settled in a completely closed state. */
            public void onDrawerClosed(View view) {
                super.onDrawerClosed(view);
                getSupportActionBar().setTitle(mTitle);
                invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            }
    
            /** Called when a drawer has settled in a completely open state. */
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                getSupportActionBar().setTitle(mDrawerTitle);
                session = new SessionManager(getApplicationContext());
                user = session.getUserDetails();
                profilepic.setImageBitmap(StringToBitMap(user.get(SessionManager.KEY_PROFILEPIC)));
                name.setText(user.get(SessionManager.KEY_NAME));
                lastsynced.setText(lastsynced());
                invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            }
        };
    
    0 讨论(0)
提交回复
热议问题