API 11日之前MultiChoiceMode [英] MultiChoiceMode before API 11

查看:204
本文介绍了API 11日之前MultiChoiceMode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现ActionMode在我的Andr​​oid应用程序与ActionBarSherlock。 有了ABS就可以API 11,但最简单的方式与以往建立一个ActionMode: listView.setMultiChoiceModeListener(新MultiChoiceModeListener()... 是不是应用程序的API 11日之前。 有没有人API 11日之前建立一个操作模式的上下文菜单的好办法? 我想打一个长按一个列表项,并开始在其中我可以点击多个项目的ActionMode。在一个简单的点击我显示列表项的细节部位。 我用的是 registerForContext()的方法,但这样做一个简单的和长期的点击。

i implement the ActionMode in my Android App with ActionBarSherlock. With ABS it is possible to build a ActionMode before API 11 but the easy way with: listView.setMultiChoiceModeListener( new MultiChoiceModeListener() ... is not for app before API 11. Has anybody a good way to build a Action Mode Context Menu before API 11? I want to make a long click on a List Item and start the ActionMode in which i can click multiple items. On a simple click i show a detail site of the list item. I use the registerForContext() method but this make a simple and long click.

有没有人一个很好的提示我。

Has anybody a good tip for me.

修改
我的问题的解决方案是以下几点:在长期的项目点击我主动的操作模式,并保存在一个变量。在项目上单击的方法我实现了if-else语句:

EDIT
The solution for my question was following: On a long item click i active the action mode and save this in a variable. In the on item click method i implement a if-else statement with:

if( actionMode == null )
{
   // open new activity or update second fragment
   showDetails( itemPosition );
}
else
{
   // update ui or close CAB if no item selected
   showCAB( itemPosition );
}

该方法showCAB(位置)更新则selectedItem计数,突出项目的背景等。

The method showCAB( position ) update the selectedItem count, highlight item background and so on.

推荐答案

好吧,我只是今天的表现,这要归功于该网站:<一href="http://www.miximum.fr/tutos/849-porting-the-contextual-anction-mode-for-$p$p-honeycomb-android-apps">http://www.miximum.fr/tutos/849-porting-the-contextual-anction-mode-for-$p$p-honeycomb-android-apps

Alright, I just did that today, thanks to that site : http://www.miximum.fr/tutos/849-porting-the-contextual-anction-mode-for-pre-honeycomb-android-apps

基本上,你只需要设置你的ListView ChoiceMode到 ListView.CHOICE_MODE_MULTIPLE ,设置 onItemClickListener 那会检查什么项目上的ListView检查,并创建一个私有类实现 ActionMode.Callback 将管理上下文动作条。

Basically, you just need to set your ListView ChoiceMode to ListView.CHOICE_MODE_MULTIPLE, to set a onItemClickListener that would check what items are checked on the ListView and to create a private class implementing ActionMode.Callback that will manage the contextual ActionBar.

我让你走在该博文看到的一切细节,有的一块codeS!

I let you go on that blogpost to see everything detailed, and some piece of codes !

这篇关于API 11日之前MultiChoiceMode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆