gpt4 book ai didi

android - 如何将上下文操作栏 (CAB) 与 support.v7.widget.Toolbar 和 Listview 一起使用?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:50:14 26 4
gpt4 key购买 nike

我正在尝试将 CAB 与 ListView 一起使用:

listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);

listView.setMultiChoiceModeListener(new ListView.MultiChoiceModeListener() {
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {

mode.setTitle(getString(R.string.list_selector_num_items_selected, listView.getCheckedItemCount()));
Log.i("LIST",position + " selected");
}

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
return true;
}
... and so on

这将创建带有默认 ActionBar 的 CAB,该 ActionBar 与我的 AppTheme 中的此条目相结合覆盖了工具栏:

<item name="windowActionModeOverlay">true</item>

这是可行的,但看起来不太好。

如果您长按电子邮件,我想要实现的功能类似于当前的 Gmail 应用程序。

任何想法如何实现这一点?


我正在使用 SupportActionBar:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
}

最佳答案

因为其他一切正常。我敢打赌这是关于造型的。您可以随时设置所有这些样式。

   <style name="AppTheme" parent="Theme.AppCompat">
<!---- other atrributes -->
<!--- changes the action mode style; height, text size, background etc -->
<item name="actionModeStyle">@style/MyActionMode</item>
<!--- changes left icon of that is used to close the action mode -->
<item name="actionModeCloseDrawable">@drawable/ic_back</item>
</style>





<style name="MyActionMode" parent="Widget.AppCompat.Base.ActionMode">
<!--- changes background of the container -->
<item name="background">?attr/colorPrimary</item>
<!--- changes the action mode background when using actionbar is splitted -->
<item name="backgroundSplit">?attr/colorPrimary</item>
<!--- changes height of the actionmode container view -->
<item name="height">@dimen/toolbar_size</item>
<!--- changes text style of the title, create your own, this is the default -->
<item name="titleTextStyle">@style/TextAppearance.AppCompat.Widget.ActionMode.Title</item>
<!--- changes text style of the subtitle, create your own, this is the default -->
<item name="subtitleTextStyle">@style/TextAppearance.AppCompat.Widget.ActionMode.Subtitle
</item>

关于android - 如何将上下文操作栏 (CAB) 与 support.v7.widget.Toolbar 和 Listview 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27572659/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com