I have created a custom AlertDialog
with multiple EditText
fields using a custom layout. Now the problem is don't know how to get data from these EditText
when user clicks. Here's the AlertDialog
.
case R.id.menu_newitem:
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.newvslayout, null);
new AlertDialog.Builder(this).setTitle("New VS")
.setView(textEntryView).setPositiveButton("Ok", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked OK so do some stuff */
}
}).setNeutralButton("Cancel", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked cancel so do some stuff */
}
}).show();
And this is my layout newvslayout.xml
....
....
<EditText android:id="@+id/vsname" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Name"
android:inputType="text" />
<EditText android:id="@+id/csize" android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="100"
android:inputType="number" />
<EditText android:id="@+id/dsize" android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="600" android:inputType="number" />
<EditText android:id="@+id/ssize" android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="200" android:inputType="number" />
....
....