无法解析构造函数匿名 MenuItem.OnMenuItemClickListener

cannot resolve constructor anonymous MenuItem.OnMenuItemClickListener

我正在使用 BottomSheet library 设置此方法给我

cannot resolve constructor anonymous MenuItem.OnMenuItemClickListener

Cannot resolve constructor 'MenuSheetView(MyProjectName.....FragmentClassName, com.flipboard.bottomsheet.commons.MenuSheetView.MenuType, java.lang.String, anonymous android.view.MenuItem.OnMenuItemClickListener)'

我做的和this library sample一样

private void TestBS(){
    bottomSheet.showWithSheetView(
            new MenuSheetView(ViewLesson.this, MenuSheetView.MenuType.LIST, "Create...", 
            new MenuItem.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    return true;
                }
            }));
}

有谁知道错误是怎么产生的

它只显示我发布的错误信息

MenuSheetView

查看课程

public class ViewLesson extends Fragment {

private Button CreateBtn;
private TextView DescriptionTV,Header;
private BottomSheetLayout bottomSheet;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    ....
    fetchData();

    return rootview;
}

private void fetchData() {....}

private void TestBS(){
    bottomSheet.showWithSheetView(
            new MenuSheetView(getContext(), MenuSheetView.MenuType.LIST, "Create...", new MenuItem.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    Log.i("dddd","ss");
                    //Toast.makeText(this, item.getTitle(), Toast.LENGTH_SHORT).show();
                    if (bottomSheet.isSheetShowing()) {
                        bottomSheet.dismissSheet();
                    }
                            /*if (item.getItemId() == R.id.reopen) {
                                showMenuSheet(menuType == MenuSheetView.MenuType.LIST ? MenuSheetView.MenuType.GRID : MenuSheetView.MenuType.LIST);
                            }*/
                    return true;
                }
            }));
}

}

getActivity()getActivity().getApplicationContext() 也不起作用

Cannot resolve constructor 'MenuSheetView(android.content.Context, com.flipboard.bottomsheet.commons.MenuSheetView.MenuType, java.lang.String, anonymous android.view.MenuItem.OnMenuItemClickListener)'

任何建议,任何解决方案?

您正在使用未定义的构造函数。这意味着您的代码与 MenuSheetView class.

的任何已知构造函数都不匹配

根据你的第一个错误,ViewLesson.this 似乎指的是一个片段,它没有扩展 Context class

正在将 new MenuItem.OnMenuItemClickListener 更改为
newMenuSheetView.OnMenuItemClickListener解决问题