从android中的其他类中删除动作模式

问题描述

每当在一个段中创建动作模式时,问题是当您转到其他段时动作模式保持打开状态。我想在底部导航栏上选择其他选项以转到不同部分时将其删除

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder>  {

 boolean isActionModeEnabled = false;

 public MyAdapter(Activity activity,List<Items> items,File file,Context mContext) {
        this.activity = activity;
        MyAdapter.items = items;
        this.file = file;
        this.mContext = mContext;
 }
  public void onBindViewHolder(@NonNull MyAdapter.MyViewHolder holder,int
         position) {

holder.itemView.setonLongClickListener(new View.OnLongClickListener() {
   @Override
   public boolean onLongClick(View v) {

   if (!isActionMode) {
     ActionMode d = new ActionMode.Callback() {
     @Override
     public boolean onCreateActionMode(ActionMode mode,Menu menu) {
        mode.getMenuInflater().inflate(R.menu.mode,menu);
        return true;
 }

}

public class ActivityOne extends AppCompatActivity {
 navbar.setonNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()){
                    case R.id.segment_one:
                        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
                        fragmentTransaction.replace(R.id.mainFragment,new Segment_One()).commit();
                        item.setChecked(true);
                        break;
                }

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)