How can I use navigation drawer (header) picture? My drawer is divided into 2 parts 1 is for drawer option (home, settings, About us) and other 1 is for header I want to make header part clickable that will redirect my MainActivity
.
Asked
Active
Viewed 84 times
-1

halfer
- 19,824
- 17
- 99
- 186

Ahsan Syed
- 29
- 8
-
can you show me your navigation xml file? – Vijay Singh Chouhan Sep 27 '18 at 11:56
-
Possible duplicate of [NavigationView get/find header layout](https://stackoverflow.com/questions/33194594/navigationview-get-find-header-layout) – Aniruddh Parihar Sep 27 '18 at 12:06
2 Answers
2
Try this out.
View headerView = getLayoutInflater().inflate(R.layout.header_navigation_drawer_social, drawerList, false);
ImageView iv = headerView.findViewById(R.id.img_profile);
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Your stuff
}
});

Vijay Singh Chouhan
- 285
- 2
- 17
1
Check this in your code:
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
After getting navigation view instance. you can get
navigationview.setOnClickListner();

Harsh Mittal
- 449
- 3
- 10