问题描述
我用 ActionMode
来选择在网格中的项目。问题是,我无法辨认是否被点击完全完成按钮。唯一我能是知道 ActionMode
结束。但是,pressing 返回完成了 ActionMode
太。期望的行为是接受的选择上完成点击,并退出 ActionMode
在返回 preSS。
I use ActionMode
to select items in a grid. The problem is that I cannot recognize whether exactly the Done button is clicked. The only I can is to know that ActionMode
is finished. But pressing Back finishes the ActionMode
too.The desired behavior is to accept selection on Done click, and exit ActionMode
on Back press.
我试图用 ActionMode.setCustomView()
,但它不影响完成按钮。该 Activity.onBack pressed()
时ActionMode开始不叫。
I tried to use ActionMode.setCustomView()
but it doesn't affect the Done button. The Activity.onBackPressed()
is not called when ActionMode is started.
在一个解决方案,我发现是使用ActionBarSherlock并手动获得完成按钮:
The one solution I've found is to use ActionBarSherlock and get the Done button manually:
View closeButton = findViewById(R.id.abs__action_mode_close_button);
但它工作在Android 2.X只-3.x的,因为4.xa本地操作栏被使用。
But it works on Android 2.x-3.x only, because on 4.x a native action bar is used.
推荐答案
请不要那样做,因为它是具体的实施极其不规范。
Please don't do that as it's implementation specific and extremely non-standard.
您可以使用 onDestroyActionMode
回调时的操作模式被驳回。
You can use the onDestroyActionMode
callback for when an action mode is dismissed.
这篇关于如何识别是否被点击ActionMode完成按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!