OnClick for navigation drawer header not working

For me other Answers didn't work. I have tried the below code. I know it's too late. Hope this will help some.

What I did to access the view of header.

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
View headerview = navigationView.getHeaderView(0);
TextView profilename = (TextView) headerview.findViewById(R.id.prof_username);
profilename.setText("your name")

for clicking the views of header, here I have used a linearlayout of headerview

LinearLayout header = (LinearLayout) headerview.findViewById(R.id.header);
header.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(HomeActivity.this, "clicked", Toast.LENGTH_SHORT).show();
            drawer.closeDrawer(GravityCompat.START);
        }
    });

Or

 headerview.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
           // Your code here 
        }
    });

Don't forget to define android:clickable="true" in your TextView xml.