[Android] common dialog box

Source: Internet
Author: User

Notification dialog box

Gets the alertdialog.builder object, through the new Builder (context) parameter: Contexts

Call the Settitle () method of the Builder Object , set the caption, parameter: text

Call the SetIcon () method of the Builder Object , set the small icon, parameter: resource ID, R.drawable.xxx

Call the setmessage () method of the Builder Object , set the contents, Parameters: Text content

Call the Setpositivebutton () method of the Builder Object , set the OK button, parameter:String 's button text, Onclicklistener object, which is an interface, an anonymous inner class implements an interface, overrides OnClick () method,

Call the Setnegativebutton () method of the Builder Object , set the Cancel button, and the parameter: same as above

Call the Builder object's create () method to get the alertdialog Object

Call the Show () method of the alertdialog object to show the dialog box

Single-selection dialog box

Gets the alertdialog.builder object, through the new Builder (context) parameter: Contexts

Call the Settitle () method of the Builder Object , set the caption, parameter: text

Call the Setsinglechoicesitems () method of the Builder object to set the radio options,

Parameter:items,checkeditem,listener

Items is an array of string[] options

Checkeditem is the index of the default selected option and is not filled in -1

Onclicklistener Object, implement it, pass in two parameters, call the dialoginterface object's dismiss () method, close the dialog box

Call the Builder object's show () method to show

The Multiple selection dialog box is almost identical to the radio dialog, except for setting the listener event

Call the Setmultichoicesitems () method of the Builder object to set the multi-select option,

Parameter:items,checkeditems,listener

Items is an array of string[] options

CheckedItems is the index of the default selected option boolean[],new boolean[]{}

Onclicklistener Object, implement it, handle it in the OnClick () method

Progress Bar dialog box (progressdialog)

Get progressdialog object, come out with new

Call the settitle () setmessage ( ) method of the progressdialog object To set the prompt information

Call the Show () method of the progressdialog Object and show it

Call the Setprogressstyle () method of the progressdialog object to set the progress style, parameters: Progressdialog.style_horizontal

Call the Setmax of the ProgressDialog object

Open a sub-thread, inside A for loop, three times, call The ProgressDialog object's Setprogress () method, thread sleep a bit, show the effect

[Android] common 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.