Notes on text in the android get dialog box. The android get dialog box
1. Set View to final type, for example, final View layout =...
2. Format EditText e = (EditText) layout. findViewById (R. id) when obtaining the text box object. // remember that layout is the final View object above.
You won't be able to get the text in the dialog box without looking at the above!
Private void getWifiInfo (){
// TODO Auto-generated method stub
/**
* When you press the return key, the prompt dialog box uses the default style.
*/
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 ();
}
How to obtain the edit box information in the dialog box in the android Program
EditText txtName = (EditText) findViewById (R. id. User Name text box ID );
String name = txtName. getText ();
Same Password
Is the layout in the dialog box taken from the XML file?
The XML should contain the ID of the text box, so there should be no problem in obtaining the text box.
In android, how does one obtain text from the Dialog box?
AlertDialog. Builder builder = new AlertDialog. Builder (this );
Builder. setMessage ("title ");
AlertDialog alert = builder. create ();
Alert. show ();
Dialog itself has nothing. What do you get?