How to implement OnFragmentInteractionListener

后端 未结 12 2640
花落未央
花落未央 2020-11-22 06:25

I have a wizard generated app with navigation drawer in android studio 0.8.2

I have created a fragment and added it with newInstance() and I get this error:

12条回答
  •  时光取名叫无心
    2020-11-22 07:20

    With me it worked delete this code:

    @Override
        public void onAttach(Context context) {
            super.onAttach(context);
            if (context instanceof OnFragmentInteractionListener) {
                mListener = (OnFragmentInteractionListener) context;
            } else {
                throw new RuntimeException(context.toString()
                        + " must implement OnFragmentInteractionListener");
            }
        }
    

    Ending like this:

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
    }
    

提交回复
热议问题