-
-
Save codeforfun-jp/688111e2d97fdc43bc6de0544c6adb19 to your computer and use it in GitHub Desktop.
Android Studio AlertDialog Pass Values to DialogFragment 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
findViewById(R.id.btn).setOnClickListener(view -> { | |
DialogFragment dialogFragment = new MyDialogFragment(); | |
// 値を渡す | |
Bundle args = new Bundle(); | |
args.putString("TITLE", "こんにちは"); | |
args.putInt("NUMBER", 123); | |
dialogFragment.setArguments(args); | |
dialogFragment.show(getSupportFragmentManager(), "my_dialog"); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment