Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Last active December 19, 2023 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeforfun-jp/00291235791953fc6fa7560dcf1a5627 to your computer and use it in GitHub Desktop.
Save codeforfun-jp/00291235791953fc6fa7560dcf1a5627 to your computer and use it in GitHub Desktop.
Android Studio AlertDialog Pass Values to DialogFragment 2
public class MyDialogFragment extends DialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
// 値を受け取る
String title = requireArguments().getString("TITLE", "");
int number = requireArguments().getInt("NUMBER", 0);
return new AlertDialog.Builder(requireActivity())
.setTitle(title)
.setMessage("受け取った値は" + number)
.setPositiveButton("OK", (dialog, id) -> {
})
.create();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment