蜂窝支持动作模式中的隐形图标

时间:2015-06-11 07:16:34

标签: android

使用支持操作模式时,蜂窝无法查看操作图标。它在2.3和4.0上可见。操作按钮实际存在,单击工作但图标不可见。 MainActivity的片段

  private ActionMode.Callback callback = new ActionMode.Callback() {
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            toolbar.setVisibility(View.GONE);
            mode.setTitle("Selected");
            mode.getMenuInflater().inflate(R.menu.action_mode, menu);               
          return true;
        }

        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
          return false;
        }

        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
          Log.d(LOG_TAG, "item " + item.getTitle());
          mode.finish();
          return false;
        }

        public void onDestroyActionMode(ActionMode mode) {
          Log.d(LOG_TAG, "destroy");
          toolbar.setVisibility(View.VISIBLE);
          actionMode = null;
        }

      };

private void enableActionMode() {
            actionMode = startSupportActionMode(callback);  

        } 

菜单文件夹

中的action_mode.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.neptunisima.learncarlogos.MainActivity">

<item android:id="@+id/action_add_favorite"
     android:title="@string/action_logo_grid"          
      android:icon="@drawable/ic_stop_white_48dp"
      app:showAsAction="ifRoom" />

的themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
 <style name="Theme.MyTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="colorPrimary">@color/teal800</item>
    <item name="colorPrimaryDark">@color/teal900</item>
    <item name="actionModeBackground">@color/teal800 </item> 
 </style>   
</resources>

0 个答案:

没有答案