IDialogpublic class ListDialog extends CommonDialog
ListDialog instance.
A list dialog box includes the radio box list and check box list.
BaseDialog.DialogListener, BaseDialog.DisplayCallback, BaseDialog.RemoveCallbackCommonDialog.DestroyedListenerIDialog.CheckBoxClickedListener, IDialog.ClickedListener, IDialog.ItemClickedListener, IDialog.KeyboardCallback| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
MULTI |
Indicates a check box list.
|
static int |
NORMAL |
Indicates a common list.
|
static int |
SINGLE |
Indicates a radio box list.
|
BUTTON_NUM, BUTTON1, BUTTON2, BUTTON3, DEF_RADIUS, ICON_NUM, ICON1, ICON2, ICON3| 构造器 | 说明 |
|---|---|
ListDialog(Context context) |
A constructor used to create a
ListDialog instance of the common type. |
ListDialog(Context context,
int type) |
A constructor used to create a
ListDialog instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
ListDialog |
addItem(String item) |
Adds an item to a
ListDialog instance. |
void |
destroy() |
Called from
BaseDialog to destroy the list dialog box. |
int |
getComponentLocation(Component component) |
Obtains the location of a specified component.
|
Component |
getItemComponent(int position) |
Obtains the component matching the item at a specified position.
|
Component |
getListContainer() |
Obtains the
ListContainer used to display content for this list dialog box. |
BaseItemProvider |
getProvider() |
Obtains the provider of this list dialog box.
|
protected void |
onShow() |
Called from
BaseDialog to initialize the content of the panels. |
ListDialog |
removeItem(String item) |
Removes an item from a
ListDialog instance. |
void |
setBackColor(int color) |
Sets the background color of a list.
|
ListDialog |
setItems(String[] items) |
Sets the items to be displayed in a list.
|
void |
setListener(ListContainer.ItemClickedListener clickListener,
ListContainer.ItemLongClickedListener longClickListener,
ListContainer.ItemSelectedListener selectedListener) |
Sets a user-defined listener for the events of an item.
|
ListDialog |
setMultiSelectItems(String[] items,
boolean[] selectedItems) |
Sets the items to be displayed in a check box list.
|
void |
setOnMultiSelectListener(IDialog.CheckBoxClickedListener listener) |
Registers a listener for check box lists.
|
void |
setOnSingleSelectListener(IDialog.ClickedListener listener) |
Registers a listener for common lists or radio box lists.
|
void |
setProvider(BaseItemProvider provider) |
Sets a specified provider for this list dialog box.
|
ListDialog |
setSingleSelectItems(String[] items,
int selectedId) |
Sets the items to be displayed in a radio box list.
|
void |
show() |
Called from
BaseDialog to show the list dialog box. |
hide, isShowing, obtainComponentViaId, onHide, onShowing, registerDisplayCallback, registerRemoveCallback, remove, searchComponentViaId, setAlignment, setAutoClosable, setCornerRadius, setDialogListener, setDuration, setOffset, setSize, setTransparentclickKeyDown, clickKeyUp, create, dealBackKeyDown, dealTouchEvent, deliverKeyboardCase, deliverTouchCase, getBoundRect, getButtonComponent, getContentCustomComponent, getWindow, isMovable, onCreate, onDestroy, onWindowConfigUpdated, onWindowSelectionUpdated, setBoundRect, setButton, setContentCustomComponent, setContentImage, setContentText, setDestroyedListener, setImageButton, setMovable, setSwipeToDismiss, setTitleCustomComponent, setTitleIcon, setTitleSubText, setTitleText, siteKeyboardCallback, siteRemovablepublic static final int MULTI
This value indicates a list with check boxes.
public static final int NORMAL
This value distinguishes the list from the list with a radio box.
public static final int SINGLE
This value indicates a list with a radio box.
public ListDialog(Context context)
ListDialog instance of the common type.
A common list is used.
context - Indicates the ohos context.public ListDialog(Context context, int type)
ListDialog instance.
Currently, a ListDialog instance supports three attributes: radio box, check box, and common list.
context - Indicates the ohos context.type - Indicates the list type, which can be the radio box, check box, or common.public void setOnSingleSelectListener(IDialog.ClickedListener listener)
This method can be used for the common and radio box lists.
listener - Indicates the listener to register.public void setOnMultiSelectListener(IDialog.CheckBoxClickedListener listener)
This method can be used for the check box lists.
listener - Indicates the listener to register.public ListDialog addItem(String item)
ListDialog instance.item - Indicates the item to add.Dialog object for continuous operations, for example, obj.setItems(items).show().public ListDialog removeItem(String item)
ListDialog instance.item - Indicates the item to remove.Dialog object for continuous operations, for example, obj.setItems(items).show().public ListDialog setItems(String[] items)
This method applies to common lists.
items - Indicates the items to be displayed in a list.Dialog object for continuous operations, for example, obj.setItems(items).show().public ListDialog setSingleSelectItems(String[] items, int selectedId)
items - Indicates the items to be displayed in a radio box list.selectedId - Indicates the item selected by default.Dialog object for continuous operations, for example, obj.setItems(items).show().public ListDialog setMultiSelectItems(String[] items, boolean[] selectedItems)
items - Indicates the items to be displayed in a check box list.selectedItems - Indicates the items selected by default.Dialog object for continuous operations, for example, obj.setItems(items).show().protected void onShow()
BaseDialog to initialize the content of the panels.onShow 在类中 CommonDialogpublic void show()
BaseDialog to show the list dialog box.show 在接口中 IDialogshow 在类中 BaseDialogpublic void destroy()
BaseDialog to destroy the list dialog box.destroy 在接口中 IDialogdestroy 在类中 BaseDialogpublic void setProvider(BaseItemProvider provider)
provider - Indicates the provider to set.
The provider allows access to the list data and creates a component for each piece of data.public void setListener(ListContainer.ItemClickedListener clickListener, ListContainer.ItemLongClickedListener longClickListener, ListContainer.ItemSelectedListener selectedListener)
clickListener - Indicates the listener for click events of the item.longClickListener - Indicates the listener for long click events of the item.selectedListener - Indicates the listener for selected events of the item.public void setBackColor(int color)
color - Indicates the user-defined background color.public BaseItemProvider getProvider()
setProvider(BaseItemProvider provider)public Component getItemComponent(int position)
position - Indicates the position specified by the user.public int getComponentLocation(Component component)
component - Indicates the component specified by the user.public Component getListContainer()
ListContainer used to display content for this list dialog box.Component object representing the ListContainer.