全部产品
云市场

卡片菜单

更新时间:2019-09-26 18:35:41

AUCardMenu 组件用于在用户点击 mPaaS 客户端首页上的卡片时弹出选择菜单,实质为弹窗(Dialog),类似 popupwindow。

效果图

WuFJSmwsvVLYPjW

依赖

参见 快速开始

接口说明

  1. ```
  2. /**
  3. * show dialog with default width
  4. * @param view
  5. * @param popItems
  6. */
  7. public void showDrop(View view, ArrayList<MessagePopItem> popItems)
  8. /**
  9. * show dialog with given width
  10. * @param view
  11. * @param popItems
  12. * @param width
  13. */
  14. public void showDrop(View view, ArrayList<MessagePopItem> popItems, int width) {
  15. int defaultMarginRight = mContext.getResources().getDimensionPixelSize(R.dimen.AU_SPACE5)/2;
  16. showDrop(view, popItems, width, defaultMarginRight);
  17. }
  18. /**
  19. * show dialog with given width & marginRight
  20. * @param view
  21. * @param popItems
  22. * @param width
  23. */
  24. public void showDrop(View view, ArrayList<MessagePopItem> popItems, int width, int marginRight)
  25. /**
  26. * show dialog with given ViewLoc
  27. * @param location
  28. * @param popItems
  29. */
  30. public void showDropWithLocation(ViewLoc location, ArrayList<MessagePopItem> popItems)
  31. 如果有网络链接的图片,需要自己下载图片
  32. public void setOnLoadImageListener(OnLoadImageListener onLoadImageListener)
  33. public interface OnLoadImageListener {
  34. /**
  35. * show dialog with given width & marginRight
  36. * @param url 图片的 URL
  37. * @param imageView 图片的目标 View
  38. * @param defaultDrawable 默认图片
  39. */
  40. public void loadImage(String url, AUImageView imageView ,Drawable defaultDrawable);
  41. }
  42. ```

自定义属性

无,不支持 XML 布局。

代码示例

  1. ArrayList<MessagePopItem> menuList = new ArrayList<MessagePopItem>();
  2. MessagePopItem item1 = new MessagePopItem();
  3. IconInfo info = new IconInfo();
  4. info.type = IconInfo.TYPE_DRAWABLE;
  5. info.drawable = getResources().getDrawable(R.drawable.menu_del_reject);
  6. item1.icon = info;
  7. item1.title = "tes1的文案就是这样";
  8. menuList.add(item1);
  9. MessagePopItem item2 = new MessagePopItem();
  10. IconInfo info2 = new IconInfo();
  11. info2.type = IconInfo.TYPE_DRAWABLE;
  12. info2.drawable = getResources().getDrawable(R.drawable.menu_delete);
  13. item2.icon = info2;
  14. item2.title = "阿斯顿发斯蒂芬";
  15. menuList.add(item2);
  16. MessagePopItem item3 = new MessagePopItem();
  17. IconInfo info3 = new IconInfo();
  18. info3.type = IconInfo.TYPE_DRAWABLE;
  19. info3.drawable = getResources().getDrawable(R.drawable.menu_ignore);
  20. item3.icon = info3;
  21. item3.title = "高速费毒黄瓜东方红";
  22. menuList.add(item3);
  23. MessagePopItem item4 = new MessagePopItem();
  24. IconInfo info4 = new IconInfo();
  25. info4.type = IconInfo.TYPE_DRAWABLE;
  26. info4.drawable = getResources().getDrawable(R.drawable.menu_reject);
  27. item4.icon = info4;
  28. item4.title = "加工费胡椒粉工行卡规范";
  29. menuList.add(item4);
  30. MessagePopItem item5 = new MessagePopItem();
  31. IconInfo info5 = new IconInfo();
  32. info5.type = IconInfo.TYPE_DRAWABLE;
  33. info5.drawable = getResources().getDrawable(R.drawable.menu_report);
  34. item5.icon = info5;
  35. item5.title = "考虑过黄金矿工法国红酒发";
  36. menuList.add(item5);
  37. final AUCardMenu popMenu = new AUCardMenu(CardMenuActivity.this);
  38. int id = v.getId();
  39. if(id == R.id.showCardMenu1) {
  40. popMenu.showDrop(textView1,menuList);
  41. }else if(id == R.id.showCardMenu2) {
  42. popMenu.showDrop(textView2,menuList);
  43. }