Ok habe das Problem selber mit der Implementation folgender Klasse gelöst...
Java: ActionBarSettings
public class ActionBarSettings {
private static DrawerLayout drawerLayout;
private static ActionBarDrawerToggle drawerToggle;
private static Toolbar toolbar;
public static void setValues(DrawerLayout layout, ActionBarDrawerToggle toggle, Toolbar bar) {
drawerLayout = layout;
drawerToggle = toggle;
toolbar = bar;
}
public static void enableUpButton(final AppCompatActivity activity) {
if (drawerLayout != null && drawerLayout != null && toolbar != null) {
drawerToggle.setDrawerIndicatorEnabled(false);
drawerToggle.setToolbarNavigationClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.onBackPressed();
}
});
Toolbar t = toolbar;
t.setNavigationIcon(activity.getDrawerToggleDelegate().getThemeUpIndicator());
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
}
}
public static void disableUpButton(final AppCompatActivity activity) {
drawerToggle.setDrawerIndicatorEnabled(true);
Toolbar t = toolbar;
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
}
}
Alles anzeigen
Das Fragment kann das dann folgender Maßen verwenden..
Java: MyFragment
public class MyFragment extends Fragment {
@Override
public void onResume() {
super.onResume();
ActionBarSettings.enableUpButton((AppCompatActivity) getActivity());
}
@Override
public void onDestroyView() {
ActionBarSettings.disableUpButton((AppCompatActivity) getActivity());
super.onDestroyView();
}
}
Alles anzeigen
LG
Adrian