AUCardMenu 組件用于在用戶單擊 mPaaS 客戶端首頁上的卡片時彈出選擇菜單,實質為彈窗(Dialog),類似 popupwindow。
效果圖
接口說明
/**
* 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);
}
文檔內容是否對您有幫助?