AUFloatMenu 组件提供一个包含图标、选项列表的菜单。
效果图
接口说明
/**
* 构造方法
*
* @param context 包含 antui-build 依赖的 activity 上下文
*/
public AUFloatMenu(Context context)
/**
* 默认靠右显示
* @param view 基于显示的 view
* @param popItems 列表显示模型
*/
@Override
public void showDrop(View view, ArrayList<MessagePopItem> popItems);
/**
* 靠左显示
* @param view 基于显示的 view
* @param popItems 列表显示模型
*/
public void showAsDropDownLeft(View view, ArrayList<MessagePopItem> popItems);
/**
* 屏幕居中显示
* @param parent 基于显示的 view
* @param title 显示列表的标题
* @param popItems 列表显示模型
*/
public void showAsDropDownTitleCenter(View parent, String title, ArrayList<MessagePopItem> popItems);
/**
* 添加显示列表条目点击事件
* @param listener
*/
public void setOnClickListener(AdapterView.OnItemClickListener listener)
代码示例
ArrayList<MessagePopItem> menuList = new ArrayList<MessagePopItem>();
MessagePopItem item1 = new MessagePopItem();
IconInfo info = new IconInfo();
info.icon = getResources().getString(R.string.iconfont_add_user);
item1.icon = info;
item1.title = "添加朋友";
menuList.add(item1);
MessagePopItem item2 = new MessagePopItem();
IconInfo info2 = new IconInfo();
info2.icon = getResources().getString(R.string.iconfont_group_chat);
item2.icon = info2;
item2.title = "群聊";
menuList.add(item2);
MessagePopItem item3 = new MessagePopItem();
IconInfo info3 = new IconInfo();
info3.icon = getResources().getString(R.string.iconfont_scan);
item3.icon = info3;
item3.title = "扫一扫";
menuList.add(item3);
MessagePopItem item4 = new MessagePopItem();
IconInfo info4 = new IconInfo();
info4.icon = getResources().getString(R.string.iconfont_collect_money);
item4.icon = info4;
item4.title = "收付款";
menuList.add(item4);
MessagePopItem item5 = new MessagePopItem();
IconInfo info5 = new IconInfo();
info5.icon = getResources().getString(R.string.iconfont_help);
item5.icon = info5;
item5.title = "使用帮助";
menuList.add(item5);
final AUFloatMenu floatMenu = new AUFloatMenu(ScrollTitleBarActivity.this);
floatMenu.showDrop(v, menuList);
floatMenu.setOnClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(ScrollTitleBarActivity.this, String.valueOf(position), Toast.LENGTH_SHORT).show();
floatMenu.hideDrop();
}
});
文档内容是否对您有帮助?