In android how to set navigation drawer header image and name programmatically in class file?

前端 未结 16 956
半阙折子戏
半阙折子戏 2020-12-04 07:53

In android studio 1.4.1, I have created new Navigation Drawer Project which is default.My issue is in this project there is nav_header_main.xml file which is for navigation

16条回答
  •  难免孤独
    2020-12-04 08:26

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    View hView =  navigationView.getHeaderView(0);
    TextView nav_user = (TextView)hView.findViewById(R.id.nav_name);
    nav_user.setText(user);
    

    hope this help!

提交回复
热议问题