0

I am using BottomSheet library setting this method giving me

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)'

I am doing it as the same as 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;
                }
            }));
}

Will anyone know from what the error is produced

It just display the error message I have posted enter image description here

MenuSheetView

ViewLesson

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() or getActivity().getApplicationContext() is not working also

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

Any suggestions, any solutions?

Dasser Basyouni
  • 3,142
  • 5
  • 26
  • 50

2 Answers2

0

You are using an undefined constructor. that means that your code does not match any known constructor of MenuSheetView class.

According to your first error it seems that ViewLesson.this refers to a fragment, that doesn't extend Context class

firegloves
  • 5,581
  • 2
  • 29
  • 50
0

Changing new MenuItem.OnMenuItemClickListener to
newMenuSheetView.OnMenuItemClickListener solves the problem

Dasser Basyouni
  • 3,142
  • 5
  • 26
  • 50