android-dialog box

Source: Internet
Author: User

android-dialog Box Steps to Implement a dialog box dialog
1 Common dialog boxes:

Alertdialog (Pop-up dialog box)


Datepickerdialog (Date selection dialog box)


Timepickerdialog (Time selection dialog box)



Build Method:

Alertdialog _alertdialog = new Alertdialog.builder (mycontentmenuactivity.this). Create ();
Builder design mode is suitable for when the construction parameters are more


2 Setup steps:
Creating an Alertdialog.builder instance in the Oncreatedialog method
Alertdialog.set the corresponding property
Build instance. Create () generates an instance of Alertdialog
Alertdialog.show (), also create () on show


3 Build button:
Call the Setpositivebutton () and Setnegativebutton () method when builder



Two custom dialog
1 direct use of the Base class dialog objects to Setcontentview to present different dialog, you can see dialog and
Activity is very similar


2 Customize with Alertdialog objects created directly Setview
Alertdialog.builder Builder = new Alertdialog.builder (getactivity ());


Get the layout inflater
Layoutinflater inflater = getactivity (). Getlayoutinflater ();


Inflate and set the layout for the dialog
Pass NULL as the parent view because its going in the dialog layout


Builder.setview (inflater.inflate (r.layout.dialog_signin, NULL))
3 If you want to customize the dialog box, use the Activity as a dialog box instead of using the dialog box API.
Simply create an activity and set the theme to Theme.Holo.Dialog in the <activity> manifest manifest element.
<activity android:theme= "@android: Style/theme.holo.dialog" >

android-dialog box

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.