First invoke navigation drawer in your main class then use this code for header image or user name
don't add header in xml add using code by inflating layout
View hView = navigationView.inflateHeaderView(R.layout.nav_header_main);
ImageView imgvw = (ImageView)hView.findViewById(R.id.imageView);
TextView tv = (TextView)hView.findViewById(R.id.textview);
imgvw .setImageResource();
tv.settext("new text");
Hint of work
@Overrideprotected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.service_main);
// Initializing Toolbar and setting it as the actionbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
navigationView = (NavigationView) findViewById(R.id.navigation_view);
View hView = navigationView.inflateHeaderView(R.layout.abc);
ImageView imgvw = (ImageView)hView.findViewById(R.id.profile_image);
TextView tv = (TextView)hView.findViewById(R.id.username);
imgvw .setImageResource(R.drawable.logo);
tv.setText("UserName");
THANKYOU!
ReplyDeleteMY APP ITS WORKING NOW!
GODBLESS!
Obrigado. Essas dicas deram certo pra mim.
ReplyDeleteit works but it duplicates the image and text
ReplyDeleteI admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much. Viking Ice Maker Repair in Los Angeles
ReplyDeleteI admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much. Installing the Sub-Zero Under-counter Refrigerator
ReplyDelete