我是android的新手,但这件事我不认为这与经验有关。 当我长按列表中的项目以显示CAB时,它显示为白色背景。我只能在长按时看到栏上的按钮,否则一切都是不可见的。我在2个不同的应用程序上使用相同的样式文件,另一个是好的。这也只发生在一台设备上。 有什么想法吗?
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Base application theme. -->
<style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:activatedBackgroundIndicator">@drawable/background_activated_drawer</item>
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background" tools:ignore="NewApi">@color/RTL_light_grey</item>
<item name="android:actionModeBackground">@color/RTL_red</item>
<item name="background">@color/RTL_dark_grey</item>
</style>
<style name="OverlayText">
<item name="android:paddingLeft">4px</item>
<item name="android:paddingBottom">4px</item>
<item name="android:textColor">#ffffffff</item>
<item name="android:textSize">12sp</item>
<item name="android:shadowColor">@color/RTL_dark_grey</item>
<item name="android:shadowDx">4</item>
<item name="android:shadowDy">4</item>
<item name="android:shadowRadius">5</item>
</style>
上下文条形码
@Override
public View onCreateView(final LayoutInflater inflater,ViewGroup parent, Bundle savedInstanceState) {
View v = super.onCreateView(inflater, parent, savedInstanceState);
ListView listView = (ListView) v.findViewById(android.R.id.list);
listView.setChoiceMode(listView.CHOICE_MODE_MULTIPLE_MODAL);
listView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
}
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
MenuInflater inflater = mode.getMenuInflater();
inflater.inflate(R.menu.tasks_context, menu);
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
TaskAdapter adapter = (TaskAdapter) getListAdapter();
TasksStorage mStorage = TasksStorage.getsTaskStorage(getActivity());
switch (item.getItemId()) {
case R.id.menu_item_delete:
for (int i = adapter.getCount() - 1; i >= 0; i--) {
if (getListView().isItemChecked(i))
mStorage.deleteTask(adapter.getItem(i));
}
//MessageBox.getMsgBox(getActivity()).saveMessages(SAVE_M);
//MessageBox.getMsgBox(getActivity()).saveMessages(SAVE_D);
mode.finish();
adapter.notifyDataSetChanged();
return true;
default:
return false;
}
}
@Override
public void onDestroyActionMode(ActionMode mode) {
}
});
return v;
}