嘿,伙计们,这是我的片段视图中的一个函数,用于在我的操作栏中动态添加一个项目。
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        // Inflate the menu; this adds items to the action bar if it is present.
         super.onCreateOptionsMenu(menu, inflater);
         fav = menu.add(1,1,1,"add");
         fav.setIcon(R.drawable.add_label);
         fav.setShowAsAction(2);
    }
我的问题是当设备被锁定并恢复时,该项目会在操作栏中自我复制。任何解决问题的见解都值得赞赏。谢谢