All Products
Search
Document Center

List dialog

Last Updated: May 25, 2021

AUListDialog (formerly APListPopDialog) provides a list dialog box containing a title, an option list, a Confirm button, and a Cancel button. Each option is a PopMenuItem with icon, option name, and selected state.

Sample image

Dependency

See Quick start.

API description

 
  1. public interface OnItemClickListener {
  2. void onItemClick(int index);
  3. }
  4. /**
  5. * Create AUListDialog based on the input list, in which the item contains only text but no image.
  6. *
  7. * @param context The context object.
  8. * @param list The string list with only ItemName instead of any image.
  9. */
  10. public AUListDialog(Context context, ArrayList<String> list)
  11. /**
  12. * Create AUListDialog based on the input list.
  13. *
  14. * @param list The PopMenuItem list.
  15. * @param context The context object.
  16. */
  17. public AUListDialog(ArrayList<PopMenuItem> list, Context context)
  18. /**
  19. * Create AUListDialog based on the input list.
  20. *
  21. * @param title The title.
  22. * @param list PopMenuItem The object list. Icons are allowed.
  23. * @param context The context object.
  24. */
  25. public AUListDialog(String title, ArrayList<PopMenuItem> list, Context context)
  26. /**
  27. * Create AUListDialog based on the input list.
  28. *
  29. * @param title The title.
  30. * @param message The message main body.
  31. * @param list PopMenuItem The object list. Icons are allowed.
  32. * @param context The context object.
  33. */
  34. public AUListDialog(String title, String message, ArrayList<PopMenuItem> list, Context context)
  35. /**
  36. * Create AUListDialog based on the input list.
  37. *
  38. * @param title The title.
  39. * @param list The PopMenuItem list.
  40. * @param showSelectionState Whether to display the icon in the selected state.
  41. * @param positiveString Confirm button text.
  42. * @param positiveListener The Confirm button listener.
  43. * @param negativeString Cancel button text.
  44. * @param negativeListener The Cancel button listener.
  45. * @param context The context object.
  46. */
  47. public AUListDialog(String title, ArrayList<PopMenuItem> list, boolean showSelectionState,
  48. String positiveString, View.OnClickListener positiveListener,
  49. String negativeString, View.OnClickListener negativeListener, Context context)
  50. /**
  51. * Create AUListDialog based on the input list.
  52. *
  53. * @param title The title.
  54. * @param message The message main body.
  55. * @param list The PopMenuItem list.
  56. * @param showSelectionState Whether to display the icon in the selected state.
  57. * @param positiveString Confirm button text.
  58. * @param positiveListener The Confirm button listener.
  59. * @param negativeString Cancel button text.
  60. * @param negativeListener The Cancel button listener.
  61. * @param context The context object.
  62. */
  63. public AUListDialog(String title, String message, ArrayList<PopMenuItem> list, boolean showSelectionState,
  64. String positiveString, View.OnClickListener positiveListener,
  65. String negativeString, View.OnClickListener negativeListener, Context context)
  66. /**
  67. * Set the list option tapping event listener.
  68. */
  69. public void setOnItemClickListener(OnItemClickListener listener) {
  70. this.listener = listener;
  71. }
  72. /**
  73. * Dynamic data refreshing API.
  74. *
  75. * @param list
  76. */
  77. public void updateData(ArrayList<PopMenuItem> list)

Sample code

  • List dialog with options only

       
    1. new AUListDialog(this, getData(7)).show();
    2. private ArrayList<String> getData(int size){
    3. ArrayList<String> data = new ArrayList<String>();
    4. for (int i= 1 ; i<= size; i++){
    5. data.add("选项文本"+ String.valueOf(i));
    6. }
    7. return data;
    8. }
  • List dialog with a title

       
    1. ArrayList<PopMenuItem> items = new ArrayList<PopMenuItem>();
    2. items.add(new PopMenuItem("选项文本", null));
    3. items.add(new PopMenuItem("选项文本", null));
    4. items.add(new PopMenuItem("选项文本", null));
    5. items.add(new PopMenuItem("选项文本", null));
    6. items.add(new PopMenuItem("选项文本", null));
    7. items.add(new PopMenuItem("选项文本", null));
    8. new AUListDialog("标题", items, this).show();
  • List dialog with description text

       
    1. ArrayList<PopMenuItem> items = new ArrayList<PopMenuItem>();
    2. items.add(new PopMenuItem("选项文本", null));
    3. items.add(new PopMenuItem("选项文本", null));
    4. items.add(new PopMenuItem("选项文本", null));
    5. new AUListDialog("", "描述文字的字数尽量控制在三行内,并且单行最右侧尽量不要是标点符号。", items, this).show();
  • List dialog with a title and description text

       
    1. ArrayList<PopMenuItem> items = new ArrayList<PopMenuItem>();
    2. items.add(new PopMenuItem("选项文本", null));
    3. items.add(new PopMenuItem("选项文本", null));
    4. items.add(new PopMenuItem("选项文本", null));
    5. new AUListDialog("标题单行", "描述文字的字数尽量控制在三行内,并且单行最右侧尽量不要是标点符号。", items, this).show();
  • List dialog with checkboxes

       
    1. ArrayList<PopMenuItem> items = new ArrayList<PopMenuItem>();
    2. PopMenuItem item = new PopMenuItem("选项文本", null);
    3. item.setType(AUCheckIcon.STATE_UNCHECKED);
    4. items.add(item);
    5. items.add(new PopMenuItem("选项文本", null));
    6. items.add(new PopMenuItem("选项文本", null));
    7. items.add(new PopMenuItem("选项文本", null));
    8. items.add(new PopMenuItem("选项文本", null));
    9. items.add(new PopMenuItem("选项文本", null));
    10. items.add(new PopMenuItem("选项文本", null));
    11. items.add(new PopMenuItem("选项文本", null));
    12. items.add(new PopMenuItem("选项文本", null));
    13. items.add(new PopMenuItem("选项文本", null));
    14. new AUListDialog("标题文字", items, true, "确定", null, "取消", null, this).show();