Menu comments
来源:互联网 发布:pe windows 编辑:程序博客网 时间:2024/05/22 14:42
1. 3 种menu
Option Menu, 显示在action bar上,不支持checked/radio button
Contextual Menu: 适用于listview/gridview 对其中的item操作
Contextual Menu contextual action mode : 占action bar的空间,在listview中可以一次对多个list item进行操作。
PopupMenu: 主要提供更多的菜单项,不应该更改view的内容
2. 菜单的定义在xml文件中,菜单有以下3中基本元素
- <menu>
- <item>
- <group>
3. Option menu
由于action bar的空间有限,可以指定在action bar的菜单项,其他未指定的都放在action overflow 中
Activity的
onCreateOptionsMenu()
创建菜单onPrepareOptionsMenu()更新菜单
invalidateOptionsMenu()
指示平台更新菜单onOptionsItemSelected()
处理菜单的点击事件
4. Contextual menu
建议使用contextual action bar, 把action item放在action bar上。
floating contextual menu简单,需要以下3个点
- 在activity中调用
registerForContextMenu(View) 指示activity 会创建contextual menu
onCreateContextMenu()
在需要时创建menuonContextItemSelected()处理菜单的点击事件
contextual action bar
public ActionMode startActionMode (ActionMode.Callback callback, int type)
ActionMode.Callback 的接口函数:
onCreateActionMode(ActionMode, Menu)
once on initial creationonPrepareActionMode(ActionMode, Menu)
after creation and any time theActionMode
is invalidatedonActionItemClicked(ActionMode, MenuItem)
any time a contextual action button is clickedonDestroyActionMode(ActionMode)
when the action mode is closed
ListView or GridView的批量数据处理
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);AbsListView.setItemChecked(int position, boolean value)
listView.setMultiChoiceModeListener(new MultiChoiceModeListener())
AbsListView.MultiChoiceModeListener 接口的处理函数 implements ActionMode.Callback
- onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked)
5. Popup Menu
PopupMenu popup = new PopupMenu(this, (View )v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.actions, popup.getMenu()); popup.show();Popup Menu listner:
interface android.widget.PopupMenu.OnMenuItemClickListener
onMenuItemClick(MenuItem item)
interface android.widget.PopupMenu.OnDismissListener
onDismiss(PopupMenu menu)
6. Menu Item可以按组处理组内的item可单选,多选
7. 自动根据intent加menuitem
需要在被加的activity支持
CATEGORY_ALTERNATIVE
and/or CATEGORY_SELECTED_ALTERNATIVE
- Menu comments
- Comments
- Comments
- struts2 comments
- Column Comments
- django comments
- Context comments
- permission comments
- Service comments
- Cursor comments
- Funny Comments
- Setting comments
- Dialog comments
- draw comments
- Fragment comments
- ASyncTask comments
- Menu
- Menu
- 负载平衡
- 使用VMware VSphere WebService SDK进行开发 (六)——检测告警信息
- Eclipse 常用快捷键
- Java并发包中的同步队列SynchronousQueue实现原理
- sicily 1155. Can I Post the lette
- Menu comments
- Spring在非web应用中关闭IoC容器 (registerShutdownHook)
- 百度翻译新版API的VB实现代码
- Maven学习总结(4)——Maven核心概念
- C# winForm webBrowser页面中js调用winForm类方法
- 使用InjectView和findViewById说拜拜
- c#在Repeater中的button如何触发onclick事件
- iOS开发多线程篇—线程安全
- iOS开发的22个奇葩技巧