5
539901
Gast
Hallo,
wie kann ich bei der Nutzung von Navigation mit 2 Fragmenten mit dem "ZurückButton" mit Safe Args eine Varibale/Argument übergeben.
Ich habe 2 Fragmente (OneFragment, TwoFragment). In der MainActivity.java verwende ich eine ActionBar mit einem DrawerLayout.
MainActivity.java:
Wenn ich nun das TwoFragment aufrufe und mit dem "ZurückButton" links oben zum OneFragment zurückkehre, möchte ich eine Variable/Argument mitgeben.
TwoFragment:
Wie kann ich das umsetzen. Wo muss ich das einbauen. Wie kann ich dem "Zurückbutton" eine Variable/Argument mit Safe Args mitgeben.
Wenn möglich in Java.
Vielen Dank für Deine Unterstützung.
Michael
wie kann ich bei der Nutzung von Navigation mit 2 Fragmenten mit dem "ZurückButton" mit Safe Args eine Varibale/Argument übergeben.
Ich habe 2 Fragmente (OneFragment, TwoFragment). In der MainActivity.java verwende ich eine ActionBar mit einem DrawerLayout.
MainActivity.java:
Java:
setSupportActionBar(binding.appBarMain.toolbar);
DrawerLayout drawer = binding.drawerLayout;
NavigationView navigationView = binding.navView;
mAppBarConfiguration = new AppBarConfiguration.Builder(R.id.homeFragment)
.setOpenableLayout(drawer)
.build();
navController = Navigation.findNavController(this, R.id.fragmentContainerView);
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, navController);
Wenn ich nun das TwoFragment aufrufe und mit dem "ZurückButton" links oben zum OneFragment zurückkehre, möchte ich eine Variable/Argument mitgeben.
TwoFragment:
Java:
ConfirmationAction action =
TwoFragmentDirections.confirmationAction();
action.setAmount(variable);
Navigation.findNavController(view).navigate(action);
Wie kann ich das umsetzen. Wo muss ich das einbauen. Wie kann ich dem "Zurückbutton" eine Variable/Argument mit Safe Args mitgeben.
Wenn möglich in Java.
Vielen Dank für Deine Unterstützung.
Michael