Use of Android alertdialog dialogue panel — Android Development

The result of the above code is shown in the figure.

Briefly record the usage of alertdialog:

The following is organized from: https://blog.csdn.net/streate/article/details/90899515

Above it are the prompt title, message body, cancel, OK and other buttons at the bottom.

-Settitle: sets the title of the dialog box, such as "prompt", "warning", etc- SetMessage: set the specific information to be conveyed in the dialog box- Seticon: icon of setting dialog box- Setcancelable: click an area outside the dialog box to make the dialog box disappear. The default value is true- Setpositivebutton: set the front button, which means "positive" and "confirm". The first parameter is the text displayed on the button, the same below- Setnegativebutton: set the negative button, which means "negative", "deny" and "Cancel"- Setneutralbutton: set neutral button- Setonshowlistener: the event triggered when the dialog box is displayed- Setoncancellistener: the event triggered when the dialog box disappears.

The contents of the list dialog box are a list of displayed contents,

You need to use the setitems method of the constructor,

The first parameter is the list data, and the second parameter is to click the listening interface,

We want to implement such a small function. When a user clicks an item, a toast will pop up to prompt the content of the selected item.

The content of the radio selection dialog box is a single selection list,

The setsinglechoiceitems method is required. The first parameter is list data,

Parameter 2 is the item selected by default, and parameter 3 is the click listening interface,

We want to implement such a small function. Users write down their choices after selecting an item,

This item will be selected by default the next time you click to open the dialog box.

The check dialog box is a list that can be selected repeatedly, which is a bit like the radio selection dialog box,

However, the setmultichoiceitems method is called, and a Boolean parameter ischecked is added,

Indicates whether the currently clicked item is selected.

We create a collection and add the selected item to the collection,

If unchecked, it will be removed from the collection. Click OK to display the selected content.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>