I want to add Filter option in Tool Bar which can be used in multiple fragments by each fragment has a different filter. For example, if I click A fragment a toolbar appears with filter option having today date, and if I click B fragment a toolbar appears with filter option having this start month date. I am getting Icon in each and every Fragment but How to use click event in the fragment
private void setupToolBar() {
drawerLayout = findViewById(R.id.drawer_layout);
initNavigationDrawer();
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawerLayout.addDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.syncState();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_filter:
Toast.makeText(this,"Main activity",Toast.LENGTH_LONG).show();
break;
default:
break;
}
return true;
}