Remove header from listView

前端 未结 7 2044
执念已碎
执念已碎 2021-02-01 04:58

I\'m having some problems when trying to remove the header from a listView. At first I use addHeaderView() to add it, but when I change to another layo

7条回答
  •  时光说笑
    2021-02-01 05:31

    Where drawerLogoView is my headerview, here's what I do:

        drawerLogoView = mInflater.inflate(R.layout.navigation_drawer_custom_layout, null);
        mDrawerList.addHeaderView(drawerLogoView,null,false);                
        LinearLayout layOut = ((LinearLayout)drawerLogoView.findViewById(R.id.NavProfilePreviewLayout));
        layOut.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, 0));
    

    That way, it becomes invisible :D To show it back, you can use this:

        LinearLayout layOut = ((LinearLayout)drawerLogoView.findViewById(R.id.NavProfilePreviewLayout));
        layOut.setLayoutParams(newRelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
    

提交回复
热议问题