i have used toolbar so now i want to apply click event over logo icon how can i get this event?
here is some coding stuff that i have done
Toolbar toolbar = null;
toolbar = (Toolbar) findViewById(R.id.actionToolbar);
setSupportActionBar(toolbar);
setTitle(null);
toolbar.setNavigationIcon(R.drawable.back);
toolbar.setNavigationContentDescription("BACK");
toolbar.setLogo(R.drawable.ic_launcher);
toolbar.setLogoDescription("LOGO");
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Nav", Toast.LENGTH_SHORT).show();
}
});
Here i have set navigation icon and logo icon so now i want logo icon's click event, how it is possible?
Long-click event behavior for the appcompat:V7 ActionBar's logo view (ImageView)
tested only android 7.0
I was asking myself the same question and came across this. I took a similar approach to Nikola Despotoski but with a different implementation.
Instead of the method, what I did was:
Slightly hack-ish, but will come back review it a bit later. Sharing for discussion purposes.
You need to get first reference of it
Using content description we can get
View
reference. See the comments inline.