Background image and image view in Navigation Drawer

前端 未结 3 487
逝去的感伤
逝去的感伤 2021-01-07 00:11

I am trying out a navigation drawer design similar to play store App: I have got the menu part things working fine but I would like to add the profile image and user id in t

3条回答
  •  抹茶落季
    2021-01-07 00:50

    Use the addHeaderView() method provided by ListView. Note: this will cause the ArrayAdapter to interpret the image as the first item in your list. To deal with this, use the option in addHeaderView to disable clicking, and move all the elements in your array up by 1 (essentially creating a dummy value at the 0th element). When your navigation drawer is first called, you may need to add a snippet like the following:

    if (savedInstanceState == null) {
                selectItem(1);
            }
    

提交回复
热议问题