Skip to content

Instantly share code, notes, and snippets.

@moradi-morteza
Last active July 29, 2020 13:27
Show Gist options
  • Save moradi-morteza/136770c372a85e524e0ebaa4320225c6 to your computer and use it in GitHub Desktop.
Save moradi-morteza/136770c372a85e524e0ebaa4320225c6 to your computer and use it in GitHub Desktop.
[android]
https://medium.com/over-engineering/hands-on-with-material-components-for-android-dialogs-75c6d726f83a
https://material.io/develop/android/components/text-fields
The basic method of showing a dialog is like so:-----------------------
// Note: A second constructor exists to pass in a theme res ID
MaterialAlertDialogBuilder(context)
// Add customization options here
.show()
Title and supporting text-------------------
// Title
.setTitle("Title")
// Supporting text
.setMessage("Supporting text")
Action buttons-----------------------------
// Confirming action
.setPositiveButton("Confirm") { dialog, which ->
// Do something for button click
}
// Dismissive action
.setNegativeButton("Dismiss") { dialog, which ->
// Do something for button click
}
// Neutral action
.setNeutralButton("Neutral") { dialog, which ->
// Do something for button click
}
--------------------------- Set View
final View customLayout = getLayoutInflater().inflate(R.layout.activity_intro, null);
final EditText et_user_name = customLayout.findViewById(R.id.et_user_name);
// define click listener or any work
new MaterialAlertDialogBuilder(getActivity())
.setView(customLayout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment