2017-12-29 6 views

答えて

1

一つの方法は、現在のヘッダビュー(removeHeaderView)を取り外し、新しいものを膨らませると、このようなNavigationViewinflateHeaderView)に設定することです:

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 
// If the view has not been set in the xml then here should be a null check because there is going to be no header view 
// and there will be no need to remove that 
View hView = navigationView.getHeaderView(0); 
navigationView.removeHeaderView(hView); 
navigationView.inflateHeaderView(R.layout.nav_my_other_header); 

HIH

完璧に動作します
+1

私が最後に変更しますあなたのソリューションのラインは、次のようになります navigationView.inflateHeaderView(R.layout.nav_my_other_header); ありがとう –

関連する問題