1. View note Set to final type such as Final view layout= ...
2, Get the text box object when the format EditText e = (EditText) Layout.findviewbyid (r.id);//Here's the layout. The final View object
You can't get the text in the dialog box without paying attention to it!
private void Getwifiinfo () {
TODO auto-generated Method Stub
/**
* The default style is used when you press the Back button in the prompt dialog box
*/
Layoutinflater Inflater=getlayoutinflater ();
Final View layout=inflater.inflate (R.layout.dialog, (ViewGroup) Findviewbyid (R.id.dialog));
New Alertdialog.builder (this).
Settitle ("Custom Layout").
Setview (Layout).
Setpositivebutton ("OK",
New Dialoginterface.onclicklistener () {
@Override
public void OnClick (Dialoginterface dialog, int which) {
EditText Et1 = (EditText) Layout.findviewbyid (r.id.wifiname);
EditText Et2 = (EditText) Layout.findviewbyid (R.id.wifipassword);
Wifiname = Et1.gettext (). toString ();
Wifipassword=et2.gettext (). toString ();
}})
. Setnegativebutton ("Cancel", null). Show ();
}
Android Get dialog box text considerations