Display ActionMode over Toolbar

后端 未结 9 1772
臣服心动
臣服心动 2020-12-02 09:59

I am trying to use the android.view.ActionMode with the new android.support.v7.widget.Toolbar, in addition to the traditional android.app.Act

9条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 10:38

    Since you are using the Toolbar, I also assume you are using the AppCompatActivity and have replaced the built in ActionBar with your custom Toolbar using setSupportActionBar(toolbar);

    First of all ensure you are importing the correct namespace:

    import androidx.appcompat.view.ActionMode;
    // Or
    import android.support.v7.view.ActionMode;
    

    and NOT

    import android.view.ActionMode;
    

    then use

    _actionMode = startSupportActionMode(this);
    

    and NOT

    _actionMode = startActionMode(this);
    

提交回复
热议问题