Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created December 19, 2023 12:21
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/9843e763c58d3adb7bec04613f24094f to your computer and use it in GitHub Desktop.
Save codeforfun-jp/9843e763c58d3adb7bec04613f24094f to your computer and use it in GitHub Desktop.
Android Studio AlertDialog Pass Values to DialogFragment - Kotlin 1
class MainActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
findViewById<Button>(R.id.btn).setOnClickListener {
val dialogFragment = MyDialogFragment()
// 値を渡す
val bundle = Bundle().apply {
putString("TITLE", "こんにちは")
putInt("NUMBER", 123)
}
dialogFragment.arguments = bundle
dialogFragment.show(supportFragmentManager, "my_dialog")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment