Skip to content

Instantly share code, notes, and snippets.

@fnovoac
Last active April 10, 2017 03:13
Show Gist options
  • Save fnovoac/51c0a8837c6ce89230cd57c15fbc2b63 to your computer and use it in GitHub Desktop.
Save fnovoac/51c0a8837c6ce89230cd57c15fbc2b63 to your computer and use it in GitHub Desktop.
CustomDialogInputWithXML.java
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_dialog_layout_design_user_input"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/dialogTitleCiudad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dialog Title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/inputDialogCiudad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Something"
android:inputType="text" />
</LinearLayout>
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(this);
mView = layoutInflaterAndroid.inflate(R.layout.custom_dialog_input, null);
//aca podemos asignar un TextView a un control del layout (si lo declaramos a nivel de clase, podemos usarlo en otro lado)
tv_inputUser = (TextView) mView.findViewById(R.id.inputDialogNombre);
new AlertDialog.Builder(this)
.setView(mView)
.setCancelable(false)
.setPositiveButton("Grabar", this) // el Activity debe implementar DialogInterface.OnClickListener para capturar el Click
.setNegativeButton("Cancelar", this) // el Activity debe implementar DialogInterface.OnClickListener para capturar el Click
.create().show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment