contextual action mode
来源:互联网 发布:安卓上的windows模拟器 编辑:程序博客网 时间:2024/06/03 15:44
在Google的开发文档的guide的menu里面,提到上下文菜单的两种形式。
There are two ways to provide contextual actions:
- In a floating context menu. A menu appears as a floating list of menu items (similar to a dialog) when the user performs a long-click (press and hold) on a view that declares support for a context menu. Users can perform a contextual action on one item at a time.
- In the contextual action mode. This mode is a system implementation of
ActionMode
that displays a contextual action bar at the top of the screen with action items that affect the selected item(s). When this mode is active, users can perform an action on multiple items at once (if your app allows it).
一种是:contextual action mode
效果图如下:
contextual action mode即是右边的那幅图。
我实现的效果如下图:
- Implement the
ActionMode.Callback
interface. In its callback methods, you can specify the actions for the contextual action bar, respond to click events on action items, and handle other lifecycle events for the action mode. - Call
startActionMode()
when you want to show the bar (such as when the user long-clicks the view).
startActionMode()
方法。第一步:
private ActionMode mActionMode;private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {// Called each time the action mode is shown. Always called after// onCreateActionMode, but// may be called multiple times if the mode is invalidated.@Overridepublic boolean onPrepareActionMode(ActionMode mode, Menu menu) {return false; // Return false if nothing is done}// Called when the action mode is created; startActionMode() was called@Overridepublic boolean onCreateActionMode(ActionMode mode, Menu menu) {// Inflate a menu resource providing context menu itemsMenuInflater inflater = mode.getMenuInflater();inflater.inflate(R.menu.game_menu, menu);return true;}@Overridepublic void onDestroyActionMode(ActionMode mode) { mActionMode = null;}@Overridepublic boolean onActionItemClicked(ActionMode mode, MenuItem item) {int id = item.getItemId();return false;}};
第二步:
mActionMode = startActionMode(mActionModeCallback);mActionMode.setTitle("title");
指定样式:
<style name="MyActionBarTheme" parent="@style/Theme.AppCompat.Light"> <item name="android:actionBarStyle">@style/MyActionBar</item> <item name="android:actionModeBackground">@android:color/holo_orange_light</item> <!-- ActionMode右边的按钮是一个特殊的CloseButton,分割线与CloseButton的Style有关 --> <!-- 删除ActionMode的Divider--> <item name="android:actionModeCloseButtonStyle">@null</item> </style> <style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar"> <item name="android:background">@android:color/holo_green_light</item> </style>
0 0
- contextual action mode
- Android contextual action mode 学习
- Android contextual action mode 学习
- Android Contextual Menus之二:contextual action mode
- Android Contextual Action Mode的使用方法
- 实现自己的Contextual Action Mode
- Contextual Action Recognition with R*CNN
- Contextual Action Recognition with R*CNN-论文阅读
- 行人属性“Contextual Action Recognition with R*CNN”
- action mode -- 标题 bar
- Android系统五种常用的 Menu!OptionMenu/ContextMenu/Actionbar/Contextual aciton mode/popup menu
- browser action mode ---windowActionModeOverlay='true' ---titlebar
- 解决:Rejected Safe Mode action : Microsoft Office Word.
- 【Android】菜单功能的实现:上下文action mode
- Prevent to cancel Action Mode by press back button
- Contextual Events简单使用
- Contextual Tab开发相关
- mode
- Qt5制作类似QQ好友鼠标悬停显示好友信息的ToolTip
- jquery模拟浏览器滚动条效果
- R语言的一些笔记
- Spring mvc中@Requestmapping再探
- LightOJ - 1040 Donation
- contextual action mode
- NSObject 类的反射,方法反射(十五)
- MongoDB简介
- AndroidFM模块学习之四源码分析(十)
- linux 挂载硬盘
- JS显示网页最后更新时间
- jq.proxy
- Uml of linux
- An internal error occurred during: "Launching web on MyEclipse Tomcat"