Android Get dialog box text considerations

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.