-1

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.

See Image

halfer
  • 19,824
  • 17
  • 99
  • 186
Ahsan Syed
  • 29
  • 8

2 Answers2

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
            }
        });
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