卡片菜单

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

效果图

AUCardMenu

接口说明

     /**
     * show dialog with default width
     * @param view
     * @param popItems
     */
    public void showDrop(View view, ArrayList<MessagePopItem> popItems)

    /**
     * show dialog with given width
     * @param view
     * @param popItems
     * @param width
     */
    public void showDrop(View view, ArrayList<MessagePopItem> popItems, int width) {
        int defaultMarginRight = mContext.getResources().getDimensionPixelSize(R.dimen.AU_SPACE5)/2;
        showDrop(view, popItems, width, defaultMarginRight);
    }

    /**
     * show dialog with given width & marginRight
     * @param view
     * @param popItems
     * @param width
     */
    public void showDrop(View view, ArrayList<MessagePopItem> popItems, int width, int marginRight)        

    /**
     * show dialog with given ViewLoc
     * @param location
     * @param popItems
     */
    public void showDropWithLocation(ViewLoc location, ArrayList<MessagePopItem> popItems) 

        如果有网络链接的图片,需要自己下载图片
        public void setOnLoadImageListener(OnLoadImageListener onLoadImageListener)

        public interface OnLoadImageListener {

                 /**
                    * show dialog with given width & marginRight
                    * @param url 图片的 URL
                    * @param imageView 图片的目标 View
                    * @param defaultDrawable  默认图片
                    */
                public void loadImage(String url, AUImageView imageView ,Drawable defaultDrawable);
        }

自定义属性

无,不支持 XML 布局。

代码示例

    ArrayList<MessagePopItem> menuList = new ArrayList<MessagePopItem>();

        MessagePopItem item1 = new MessagePopItem();
        IconInfo info = new IconInfo();
        info.type = IconInfo.TYPE_DRAWABLE;
        info.drawable = getResources().getDrawable(R.drawable.menu_del_reject);
        item1.icon = info;
        item1.title = "示例文本 1";
        menuList.add(item1);


        MessagePopItem item2 = new MessagePopItem();
        IconInfo info2 = new IconInfo();
        info2.type = IconInfo.TYPE_DRAWABLE;
        info2.drawable = getResources().getDrawable(R.drawable.menu_delete);
        item2.icon = info2;
        item2.title = "示例文本 2";
        menuList.add(item2);

        MessagePopItem item3 = new MessagePopItem();
        IconInfo info3 = new IconInfo();
        info3.type = IconInfo.TYPE_DRAWABLE;
        info3.drawable = getResources().getDrawable(R.drawable.menu_ignore);
        item3.icon = info3;
        item3.title = "示例文本 3";
        menuList.add(item3);

        MessagePopItem item4 = new MessagePopItem();
        IconInfo info4 = new IconInfo();
        info4.type = IconInfo.TYPE_DRAWABLE;
        info4.drawable = getResources().getDrawable(R.drawable.menu_reject);
        item4.icon = info4;
        item4.title = "示例文本 4";
        menuList.add(item4);

        MessagePopItem item5 = new MessagePopItem();
        IconInfo info5 = new IconInfo();
        info5.type = IconInfo.TYPE_DRAWABLE;
        info5.drawable = getResources().getDrawable(R.drawable.menu_report);
        item5.icon = info5;
        item5.title = "示例文本 5";
        menuList.add(item5);

        final AUCardMenu popMenu = new AUCardMenu(CardMenuActivity.this);
        int id = v.getId();
        if(id == R.id.showCardMenu1) {
            popMenu.showDrop(textView1,menuList);
        }else if(id == R.id.showCardMenu2) {
            popMenu.showDrop(textView2,menuList);
        }