Xya*_*ren 6 android android-appcompat android-support-library contextual-action-bar android-actionbar-compat
我正在尝试使用带有ListView的CAB:
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
Run Code Online (Sandbox Code Playgroud)
这将创建具有默认ActionBar的CAB,该ActionBar与我在AppTheme中的此条目一起覆盖工具栏:
<item name="windowActionModeOverlay">true</item>
Run Code Online (Sandbox Code Playgroud)
这是工作但它看起来不是很好.
如果您长按电子邮件,我想要实现的目标与当前的Gmail应用程序类似.
任何想法如何实现这一目标?
我正在使用SupportActionBar:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
}
Run Code Online (Sandbox Code Playgroud)
因为其他一切都有效.我打赌这是关于造型.你可以随时设计这一切.
<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>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2516 次 |
最近记录: |