android 长按菜单的使用
2011-11-03 11:29
225 查看
//在创建时注册 registerForContextMenu(ctrList); /************** *生成长按菜单 **************/ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if(v.getId()==R.id.list_Importing) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.black_list_context_menu_imporiting, menu); }else { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.black_list_context_menu, menu); menu.setHeaderTitle(mList.get(info.position).num); } super.onCreateContextMenu(menu, v, menuInfo); } //处理菜单事件 public boolean onContextItemSelected(MenuItem item) { final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); // info.position switch (item.getItemId()) { case R.id.menu_item_delete_this: break; case R.id.menu_item_delete_all: break; } return super.onContextItemSelected(item); }
相关文章推荐
- android开发 - 菜单的使用
- android下使用Fragment实现左侧3级菜单+动画效果
- Android菜单使用
- android各种菜单使用介绍
- 使用nineoldandroids仿制QQ侧滑菜单
- Android组件——使用DrawerLayout仿网易新闻v4.4侧滑菜单
- Android入门(44)——第六章 使用OptionsMenu实现选项菜单
- Android 菜单(Menu)控件的使用
- Android中使用PreferenceActivity创建菜单
- Android 中MenuInflater的使用(布局定义菜单
- Android SlidingMenu侧滑菜单使用
- Android菜单详解(五)——使用XML生成菜单
- Android使用Popupwindow实现悬浮菜单功能
- Android中弹出菜单PopupWindow的使用
- Android使用Activity实现从底部弹出菜单或窗口的方法
- Android5.0之NavigationView的使用 。android组件之DrawerLayout(抽屉导航)-- 侧滑菜单效果
- Android 中MenuInflater的使用(布局定义菜单)!
- 初学Android,使用菜单资源(十九) .
- Android学习之menu菜单使用与用户自定义View
- Android 游戏中使用的 左右滑动菜单