how to intent from recyclerview to fragment












0














I want to apply intent to my Fragment from my SeriesVBAdapter, but I get an error. I implemented the interface, but I cannot find the solution. I wanted to send data from SeriesVBAdapter to DescriptionFragment. In doing so, I tried SeriesVBAdapter to DescriptionActivity then DescriptionFragment, but I got the error.



(The solutions on the site mixed my head more.)



SeriesListener



public interface SeriesListener {void seriesKnowledge(String title,String desc,int thumb);}


SeriesRVAdapter



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

private Context mContext;
private List<SeriesDB> mData;
private SeriesListener mSeriesListener;

public SeriesRVAdapter(Context mContext, List<SeriesDB> mData) {
this.mContext = mContext;
this.mData = mData;
}

@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

View view;
LayoutInflater mInflater = LayoutInflater.from(mContext);
view = mInflater.inflate(R.layout.cardview_item_categories,parent,false);
MyViewHolder holder = new MyViewHolder(view,mSeriesListener);
return holder;
}

@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, final int position) {

holder.seriesTitle.setText(mData.get(position).getTitle());
holder.seriesImage.setImageResource(mData.get(position).getThumbnail());
holder.cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mSeriesListener.seriesKnowledge(mData.get(position).getTitle(),mData.get(position).getDescription(),mData.get(position).getThumbnail());
}
});
}

@Override
public int getItemCount() {
return mData.size();
}

public static class MyViewHolder extends RecyclerView.ViewHolder{

TextView seriesTitle;
ImageView seriesImage;
CardView cardView;
SeriesListener mSeriesListener;

public MyViewHolder(View itemView, SeriesListener seriesListener){
super(itemView);

seriesTitle = itemView.findViewById(R.id.series_title_id);
seriesImage = itemView.findViewById(R.id.series_img_id);
cardView = itemView.findViewById(R.id.cardview_series_id);
mSeriesListener = seriesListener;
}

}
}


DescriptionActivity



public class DescriptionActivity extends AppCompatActivity implements  SeriesListener{

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_description);
}


@Override
public void seriesKnowledge(String title, String desc, int thumb) {

FragmentManager manager = getFragmentManager();

DecriptionFragment decriptionFragment = (DecriptionFragment) manager.findFragmentById(R.id.description_fr);
decriptionFragment.sendData(title,desc,thumb);

}
}


DecriptionFragment



public class DecriptionFragment extends Fragment {

View view;
ImageView img;
TextView tx1;
TextView tx2;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_description,container,false);

img = view.findViewById(R.id.description_image_id);
tx1 = view.findViewById(R.id.description_series_id);
tx2 = view.findViewById(R.id.description_series_category);

return view;
}

public void sendData(String title, String desc, int thumb)
{
img.setImageResource(thumb);
tx1.setText(title);
tx2.setText(desc);
}
}


CategoriesFragment



public class CategoriesFragment extends Fragment {



View view;
List<SeriesDB> seriesDBS;

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_categories, container, false);

seriesDBS = new ArrayList<>();
seriesDBS.add(new SeriesDB("Arrow", "Crime","Decription Arrow",R.drawable.arrow));
seriesDBS.add(new SeriesDB("Flash", "Crime","Decription Flash",R.drawable.flash));
seriesDBS.add(new SeriesDB("Supernatural", "Crime","Decription Supernatural",R.drawable.supernatural));
seriesDBS.add(new SeriesDB("The Originals", "Crime","Decription Originals",R.drawable.originals));
seriesDBS.add(new SeriesDB("The Legacies", "Crime","Decription Legacies",R.drawable.legacies));
seriesDBS.add(new SeriesDB("Peaky Blinders", "Crime","Decription Peaky Blinders",R.drawable.peaky));
seriesDBS.add(new SeriesDB("Arrow", "Crime","Decription Arrow",R.drawable.arrow));
seriesDBS.add(new SeriesDB("Flash", "Crime","Decription Flash",R.drawable.flash));
seriesDBS.add(new SeriesDB("Supernatural", "Crime","Decription Supernatural",R.drawable.supernatural));
seriesDBS.add(new SeriesDB("The Originals", "Crime","Decription Originals",R.drawable.originals));
seriesDBS.add(new SeriesDB("The Legacies", "Crime","Decription Legacies",R.drawable.legacies));
seriesDBS.add(new SeriesDB("Peaky Blinders", "Crime","Decription Peaky Blinders",R.drawable.peaky));

RecyclerView myrv = (RecyclerView) view.findViewById(R.id.recyclerView_series_id);
SeriesRVAdapter myAdapter = new SeriesRVAdapter(getActivity(),seriesDBS);
myrv.setLayoutManager(new GridLayoutManager(getContext(),3));
myrv.setAdapter(myAdapter);
return view;
}


}




--------- beginning of crash


2018-12-02 17:44:33.663 6704-6704/com.example.forev.neizledim E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.forev.neizledim, PID: 6704
java.lang.NullPointerException: Attempt to invoke interface method 'void com.example.forev.neizledim.SeriesListener.seriesKnowledge(java.lang.String, java.lang.String, int)' on a null object reference
at com.example.forev.neizledim.adapter.recyclerview.SeriesRVAdapter$1.onClick(SeriesRVAdapter.java:49)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)











share|improve this question







New contributor




Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0














    I want to apply intent to my Fragment from my SeriesVBAdapter, but I get an error. I implemented the interface, but I cannot find the solution. I wanted to send data from SeriesVBAdapter to DescriptionFragment. In doing so, I tried SeriesVBAdapter to DescriptionActivity then DescriptionFragment, but I got the error.



    (The solutions on the site mixed my head more.)



    SeriesListener



    public interface SeriesListener {void seriesKnowledge(String title,String desc,int thumb);}


    SeriesRVAdapter



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

    private Context mContext;
    private List<SeriesDB> mData;
    private SeriesListener mSeriesListener;

    public SeriesRVAdapter(Context mContext, List<SeriesDB> mData) {
    this.mContext = mContext;
    this.mData = mData;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

    View view;
    LayoutInflater mInflater = LayoutInflater.from(mContext);
    view = mInflater.inflate(R.layout.cardview_item_categories,parent,false);
    MyViewHolder holder = new MyViewHolder(view,mSeriesListener);
    return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, final int position) {

    holder.seriesTitle.setText(mData.get(position).getTitle());
    holder.seriesImage.setImageResource(mData.get(position).getThumbnail());
    holder.cardView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
    mSeriesListener.seriesKnowledge(mData.get(position).getTitle(),mData.get(position).getDescription(),mData.get(position).getThumbnail());
    }
    });
    }

    @Override
    public int getItemCount() {
    return mData.size();
    }

    public static class MyViewHolder extends RecyclerView.ViewHolder{

    TextView seriesTitle;
    ImageView seriesImage;
    CardView cardView;
    SeriesListener mSeriesListener;

    public MyViewHolder(View itemView, SeriesListener seriesListener){
    super(itemView);

    seriesTitle = itemView.findViewById(R.id.series_title_id);
    seriesImage = itemView.findViewById(R.id.series_img_id);
    cardView = itemView.findViewById(R.id.cardview_series_id);
    mSeriesListener = seriesListener;
    }

    }
    }


    DescriptionActivity



    public class DescriptionActivity extends AppCompatActivity implements  SeriesListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_description);
    }


    @Override
    public void seriesKnowledge(String title, String desc, int thumb) {

    FragmentManager manager = getFragmentManager();

    DecriptionFragment decriptionFragment = (DecriptionFragment) manager.findFragmentById(R.id.description_fr);
    decriptionFragment.sendData(title,desc,thumb);

    }
    }


    DecriptionFragment



    public class DecriptionFragment extends Fragment {

    View view;
    ImageView img;
    TextView tx1;
    TextView tx2;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.fragment_description,container,false);

    img = view.findViewById(R.id.description_image_id);
    tx1 = view.findViewById(R.id.description_series_id);
    tx2 = view.findViewById(R.id.description_series_category);

    return view;
    }

    public void sendData(String title, String desc, int thumb)
    {
    img.setImageResource(thumb);
    tx1.setText(title);
    tx2.setText(desc);
    }
    }


    CategoriesFragment



    public class CategoriesFragment extends Fragment {



    View view;
    List<SeriesDB> seriesDBS;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.fragment_categories, container, false);

    seriesDBS = new ArrayList<>();
    seriesDBS.add(new SeriesDB("Arrow", "Crime","Decription Arrow",R.drawable.arrow));
    seriesDBS.add(new SeriesDB("Flash", "Crime","Decription Flash",R.drawable.flash));
    seriesDBS.add(new SeriesDB("Supernatural", "Crime","Decription Supernatural",R.drawable.supernatural));
    seriesDBS.add(new SeriesDB("The Originals", "Crime","Decription Originals",R.drawable.originals));
    seriesDBS.add(new SeriesDB("The Legacies", "Crime","Decription Legacies",R.drawable.legacies));
    seriesDBS.add(new SeriesDB("Peaky Blinders", "Crime","Decription Peaky Blinders",R.drawable.peaky));
    seriesDBS.add(new SeriesDB("Arrow", "Crime","Decription Arrow",R.drawable.arrow));
    seriesDBS.add(new SeriesDB("Flash", "Crime","Decription Flash",R.drawable.flash));
    seriesDBS.add(new SeriesDB("Supernatural", "Crime","Decription Supernatural",R.drawable.supernatural));
    seriesDBS.add(new SeriesDB("The Originals", "Crime","Decription Originals",R.drawable.originals));
    seriesDBS.add(new SeriesDB("The Legacies", "Crime","Decription Legacies",R.drawable.legacies));
    seriesDBS.add(new SeriesDB("Peaky Blinders", "Crime","Decription Peaky Blinders",R.drawable.peaky));

    RecyclerView myrv = (RecyclerView) view.findViewById(R.id.recyclerView_series_id);
    SeriesRVAdapter myAdapter = new SeriesRVAdapter(getActivity(),seriesDBS);
    myrv.setLayoutManager(new GridLayoutManager(getContext(),3));
    myrv.setAdapter(myAdapter);
    return view;
    }


    }




    --------- beginning of crash


    2018-12-02 17:44:33.663 6704-6704/com.example.forev.neizledim E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.forev.neizledim, PID: 6704
    java.lang.NullPointerException: Attempt to invoke interface method 'void com.example.forev.neizledim.SeriesListener.seriesKnowledge(java.lang.String, java.lang.String, int)' on a null object reference
    at com.example.forev.neizledim.adapter.recyclerview.SeriesRVAdapter$1.onClick(SeriesRVAdapter.java:49)
    at android.view.View.performClick(View.java:5637)
    at android.view.View$PerformClick.run(View.java:22429)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)











    share|improve this question







    New contributor




    Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0







      I want to apply intent to my Fragment from my SeriesVBAdapter, but I get an error. I implemented the interface, but I cannot find the solution. I wanted to send data from SeriesVBAdapter to DescriptionFragment. In doing so, I tried SeriesVBAdapter to DescriptionActivity then DescriptionFragment, but I got the error.



      (The solutions on the site mixed my head more.)



      SeriesListener



      public interface SeriesListener {void seriesKnowledge(String title,String desc,int thumb);}


      SeriesRVAdapter



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

      private Context mContext;
      private List<SeriesDB> mData;
      private SeriesListener mSeriesListener;

      public SeriesRVAdapter(Context mContext, List<SeriesDB> mData) {
      this.mContext = mContext;
      this.mData = mData;
      }

      @NonNull
      @Override
      public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

      View view;
      LayoutInflater mInflater = LayoutInflater.from(mContext);
      view = mInflater.inflate(R.layout.cardview_item_categories,parent,false);
      MyViewHolder holder = new MyViewHolder(view,mSeriesListener);
      return holder;
      }

      @Override
      public void onBindViewHolder(@NonNull MyViewHolder holder, final int position) {

      holder.seriesTitle.setText(mData.get(position).getTitle());
      holder.seriesImage.setImageResource(mData.get(position).getThumbnail());
      holder.cardView.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
      mSeriesListener.seriesKnowledge(mData.get(position).getTitle(),mData.get(position).getDescription(),mData.get(position).getThumbnail());
      }
      });
      }

      @Override
      public int getItemCount() {
      return mData.size();
      }

      public static class MyViewHolder extends RecyclerView.ViewHolder{

      TextView seriesTitle;
      ImageView seriesImage;
      CardView cardView;
      SeriesListener mSeriesListener;

      public MyViewHolder(View itemView, SeriesListener seriesListener){
      super(itemView);

      seriesTitle = itemView.findViewById(R.id.series_title_id);
      seriesImage = itemView.findViewById(R.id.series_img_id);
      cardView = itemView.findViewById(R.id.cardview_series_id);
      mSeriesListener = seriesListener;
      }

      }
      }


      DescriptionActivity



      public class DescriptionActivity extends AppCompatActivity implements  SeriesListener{

      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_description);
      }


      @Override
      public void seriesKnowledge(String title, String desc, int thumb) {

      FragmentManager manager = getFragmentManager();

      DecriptionFragment decriptionFragment = (DecriptionFragment) manager.findFragmentById(R.id.description_fr);
      decriptionFragment.sendData(title,desc,thumb);

      }
      }


      DecriptionFragment



      public class DecriptionFragment extends Fragment {

      View view;
      ImageView img;
      TextView tx1;
      TextView tx2;

      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
      view = inflater.inflate(R.layout.fragment_description,container,false);

      img = view.findViewById(R.id.description_image_id);
      tx1 = view.findViewById(R.id.description_series_id);
      tx2 = view.findViewById(R.id.description_series_category);

      return view;
      }

      public void sendData(String title, String desc, int thumb)
      {
      img.setImageResource(thumb);
      tx1.setText(title);
      tx2.setText(desc);
      }
      }


      CategoriesFragment



      public class CategoriesFragment extends Fragment {



      View view;
      List<SeriesDB> seriesDBS;

      @Nullable
      @Override
      public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      view = inflater.inflate(R.layout.fragment_categories, container, false);

      seriesDBS = new ArrayList<>();
      seriesDBS.add(new SeriesDB("Arrow", "Crime","Decription Arrow",R.drawable.arrow));
      seriesDBS.add(new SeriesDB("Flash", "Crime","Decription Flash",R.drawable.flash));
      seriesDBS.add(new SeriesDB("Supernatural", "Crime","Decription Supernatural",R.drawable.supernatural));
      seriesDBS.add(new SeriesDB("The Originals", "Crime","Decription Originals",R.drawable.originals));
      seriesDBS.add(new SeriesDB("The Legacies", "Crime","Decription Legacies",R.drawable.legacies));
      seriesDBS.add(new SeriesDB("Peaky Blinders", "Crime","Decription Peaky Blinders",R.drawable.peaky));
      seriesDBS.add(new SeriesDB("Arrow", "Crime","Decription Arrow",R.drawable.arrow));
      seriesDBS.add(new SeriesDB("Flash", "Crime","Decription Flash",R.drawable.flash));
      seriesDBS.add(new SeriesDB("Supernatural", "Crime","Decription Supernatural",R.drawable.supernatural));
      seriesDBS.add(new SeriesDB("The Originals", "Crime","Decription Originals",R.drawable.originals));
      seriesDBS.add(new SeriesDB("The Legacies", "Crime","Decription Legacies",R.drawable.legacies));
      seriesDBS.add(new SeriesDB("Peaky Blinders", "Crime","Decription Peaky Blinders",R.drawable.peaky));

      RecyclerView myrv = (RecyclerView) view.findViewById(R.id.recyclerView_series_id);
      SeriesRVAdapter myAdapter = new SeriesRVAdapter(getActivity(),seriesDBS);
      myrv.setLayoutManager(new GridLayoutManager(getContext(),3));
      myrv.setAdapter(myAdapter);
      return view;
      }


      }




      --------- beginning of crash


      2018-12-02 17:44:33.663 6704-6704/com.example.forev.neizledim E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.forev.neizledim, PID: 6704
      java.lang.NullPointerException: Attempt to invoke interface method 'void com.example.forev.neizledim.SeriesListener.seriesKnowledge(java.lang.String, java.lang.String, int)' on a null object reference
      at com.example.forev.neizledim.adapter.recyclerview.SeriesRVAdapter$1.onClick(SeriesRVAdapter.java:49)
      at android.view.View.performClick(View.java:5637)
      at android.view.View$PerformClick.run(View.java:22429)
      at android.os.Handler.handleCallback(Handler.java:751)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:154)
      at android.app.ActivityThread.main(ActivityThread.java:6119)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)











      share|improve this question







      New contributor




      Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I want to apply intent to my Fragment from my SeriesVBAdapter, but I get an error. I implemented the interface, but I cannot find the solution. I wanted to send data from SeriesVBAdapter to DescriptionFragment. In doing so, I tried SeriesVBAdapter to DescriptionActivity then DescriptionFragment, but I got the error.



      (The solutions on the site mixed my head more.)



      SeriesListener



      public interface SeriesListener {void seriesKnowledge(String title,String desc,int thumb);}


      SeriesRVAdapter



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

      private Context mContext;
      private List<SeriesDB> mData;
      private SeriesListener mSeriesListener;

      public SeriesRVAdapter(Context mContext, List<SeriesDB> mData) {
      this.mContext = mContext;
      this.mData = mData;
      }

      @NonNull
      @Override
      public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

      View view;
      LayoutInflater mInflater = LayoutInflater.from(mContext);
      view = mInflater.inflate(R.layout.cardview_item_categories,parent,false);
      MyViewHolder holder = new MyViewHolder(view,mSeriesListener);
      return holder;
      }

      @Override
      public void onBindViewHolder(@NonNull MyViewHolder holder, final int position) {

      holder.seriesTitle.setText(mData.get(position).getTitle());
      holder.seriesImage.setImageResource(mData.get(position).getThumbnail());
      holder.cardView.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
      mSeriesListener.seriesKnowledge(mData.get(position).getTitle(),mData.get(position).getDescription(),mData.get(position).getThumbnail());
      }
      });
      }

      @Override
      public int getItemCount() {
      return mData.size();
      }

      public static class MyViewHolder extends RecyclerView.ViewHolder{

      TextView seriesTitle;
      ImageView seriesImage;
      CardView cardView;
      SeriesListener mSeriesListener;

      public MyViewHolder(View itemView, SeriesListener seriesListener){
      super(itemView);

      seriesTitle = itemView.findViewById(R.id.series_title_id);
      seriesImage = itemView.findViewById(R.id.series_img_id);
      cardView = itemView.findViewById(R.id.cardview_series_id);
      mSeriesListener = seriesListener;
      }

      }
      }


      DescriptionActivity



      public class DescriptionActivity extends AppCompatActivity implements  SeriesListener{

      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_description);
      }


      @Override
      public void seriesKnowledge(String title, String desc, int thumb) {

      FragmentManager manager = getFragmentManager();

      DecriptionFragment decriptionFragment = (DecriptionFragment) manager.findFragmentById(R.id.description_fr);
      decriptionFragment.sendData(title,desc,thumb);

      }
      }


      DecriptionFragment



      public class DecriptionFragment extends Fragment {

      View view;
      ImageView img;
      TextView tx1;
      TextView tx2;

      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
      view = inflater.inflate(R.layout.fragment_description,container,false);

      img = view.findViewById(R.id.description_image_id);
      tx1 = view.findViewById(R.id.description_series_id);
      tx2 = view.findViewById(R.id.description_series_category);

      return view;
      }

      public void sendData(String title, String desc, int thumb)
      {
      img.setImageResource(thumb);
      tx1.setText(title);
      tx2.setText(desc);
      }
      }


      CategoriesFragment



      public class CategoriesFragment extends Fragment {



      View view;
      List<SeriesDB> seriesDBS;

      @Nullable
      @Override
      public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      view = inflater.inflate(R.layout.fragment_categories, container, false);

      seriesDBS = new ArrayList<>();
      seriesDBS.add(new SeriesDB("Arrow", "Crime","Decription Arrow",R.drawable.arrow));
      seriesDBS.add(new SeriesDB("Flash", "Crime","Decription Flash",R.drawable.flash));
      seriesDBS.add(new SeriesDB("Supernatural", "Crime","Decription Supernatural",R.drawable.supernatural));
      seriesDBS.add(new SeriesDB("The Originals", "Crime","Decription Originals",R.drawable.originals));
      seriesDBS.add(new SeriesDB("The Legacies", "Crime","Decription Legacies",R.drawable.legacies));
      seriesDBS.add(new SeriesDB("Peaky Blinders", "Crime","Decription Peaky Blinders",R.drawable.peaky));
      seriesDBS.add(new SeriesDB("Arrow", "Crime","Decription Arrow",R.drawable.arrow));
      seriesDBS.add(new SeriesDB("Flash", "Crime","Decription Flash",R.drawable.flash));
      seriesDBS.add(new SeriesDB("Supernatural", "Crime","Decription Supernatural",R.drawable.supernatural));
      seriesDBS.add(new SeriesDB("The Originals", "Crime","Decription Originals",R.drawable.originals));
      seriesDBS.add(new SeriesDB("The Legacies", "Crime","Decription Legacies",R.drawable.legacies));
      seriesDBS.add(new SeriesDB("Peaky Blinders", "Crime","Decription Peaky Blinders",R.drawable.peaky));

      RecyclerView myrv = (RecyclerView) view.findViewById(R.id.recyclerView_series_id);
      SeriesRVAdapter myAdapter = new SeriesRVAdapter(getActivity(),seriesDBS);
      myrv.setLayoutManager(new GridLayoutManager(getContext(),3));
      myrv.setAdapter(myAdapter);
      return view;
      }


      }




      --------- beginning of crash


      2018-12-02 17:44:33.663 6704-6704/com.example.forev.neizledim E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.forev.neizledim, PID: 6704
      java.lang.NullPointerException: Attempt to invoke interface method 'void com.example.forev.neizledim.SeriesListener.seriesKnowledge(java.lang.String, java.lang.String, int)' on a null object reference
      at com.example.forev.neizledim.adapter.recyclerview.SeriesRVAdapter$1.onClick(SeriesRVAdapter.java:49)
      at android.view.View.performClick(View.java:5637)
      at android.view.View$PerformClick.run(View.java:22429)
      at android.os.Handler.handleCallback(Handler.java:751)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:154)
      at android.app.ActivityThread.main(ActivityThread.java:6119)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)








      android






      share|improve this question







      New contributor




      Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Dec 27 '18 at 15:28









      Furkan

      11




      11




      New contributor




      Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          You are having a nullpointer exception at the onClick method inside you adapter because of mSeriesListener is not initialized so add this to SeriesRVAdapter :



          public void setSeriesListener(SeriesListener mSeriesListener) {
          this.mSeriesListener = mSeriesListener;
          }


          and this to CategoriesFragment :



          SeriesRVAdapter myAdapter = new SeriesRVAdapter(getActivity(),seriesDBS);
          myAdapter.setSeriesListener(this);


          and implement the seriesKnowledge method at the CategoriesFragment:



          public void seriesKnowledge(String title,String desc,int thumb){
          }





          share|improve this answer























          • I'm sorry, I don't know exactly where to add it. You said that I should implement it, but if I implement it, will I have to delete the other parties? Normally I wrote as a private message, but I am not able to understand the operation on the site so I answer again here. Can we contact your twitter if I can't solve it again?
            – Furkan
            Dec 27 '18 at 15:52










          • I updated my answer I hope it's clear now, you don't need to delete anything
            – Oussema Aroua
            Dec 27 '18 at 15:56










          • Application shutdown problem is solved but does not intent. The application does not close at the moment but my button does not make any intent when I click.
            – Furkan
            Dec 27 '18 at 16:08










          • i cant solve the problem @Oussema Aroua
            – Furkan
            Dec 28 '18 at 23:42





















          0














          I still haven't figured out the problem yet. I've solved the problem of stopping the application with the comments given by @OussemaAroua , but this time it was not intent. I tried through another solution from another site did intent but didn't pass my data. How can I solve the problem?






          share|improve this answer








          New contributor




          Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.


















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            Furkan is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53947335%2fhow-to-intent-from-recyclerview-to-fragment%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You are having a nullpointer exception at the onClick method inside you adapter because of mSeriesListener is not initialized so add this to SeriesRVAdapter :



            public void setSeriesListener(SeriesListener mSeriesListener) {
            this.mSeriesListener = mSeriesListener;
            }


            and this to CategoriesFragment :



            SeriesRVAdapter myAdapter = new SeriesRVAdapter(getActivity(),seriesDBS);
            myAdapter.setSeriesListener(this);


            and implement the seriesKnowledge method at the CategoriesFragment:



            public void seriesKnowledge(String title,String desc,int thumb){
            }





            share|improve this answer























            • I'm sorry, I don't know exactly where to add it. You said that I should implement it, but if I implement it, will I have to delete the other parties? Normally I wrote as a private message, but I am not able to understand the operation on the site so I answer again here. Can we contact your twitter if I can't solve it again?
              – Furkan
              Dec 27 '18 at 15:52










            • I updated my answer I hope it's clear now, you don't need to delete anything
              – Oussema Aroua
              Dec 27 '18 at 15:56










            • Application shutdown problem is solved but does not intent. The application does not close at the moment but my button does not make any intent when I click.
              – Furkan
              Dec 27 '18 at 16:08










            • i cant solve the problem @Oussema Aroua
              – Furkan
              Dec 28 '18 at 23:42


















            0














            You are having a nullpointer exception at the onClick method inside you adapter because of mSeriesListener is not initialized so add this to SeriesRVAdapter :



            public void setSeriesListener(SeriesListener mSeriesListener) {
            this.mSeriesListener = mSeriesListener;
            }


            and this to CategoriesFragment :



            SeriesRVAdapter myAdapter = new SeriesRVAdapter(getActivity(),seriesDBS);
            myAdapter.setSeriesListener(this);


            and implement the seriesKnowledge method at the CategoriesFragment:



            public void seriesKnowledge(String title,String desc,int thumb){
            }





            share|improve this answer























            • I'm sorry, I don't know exactly where to add it. You said that I should implement it, but if I implement it, will I have to delete the other parties? Normally I wrote as a private message, but I am not able to understand the operation on the site so I answer again here. Can we contact your twitter if I can't solve it again?
              – Furkan
              Dec 27 '18 at 15:52










            • I updated my answer I hope it's clear now, you don't need to delete anything
              – Oussema Aroua
              Dec 27 '18 at 15:56










            • Application shutdown problem is solved but does not intent. The application does not close at the moment but my button does not make any intent when I click.
              – Furkan
              Dec 27 '18 at 16:08










            • i cant solve the problem @Oussema Aroua
              – Furkan
              Dec 28 '18 at 23:42
















            0












            0








            0






            You are having a nullpointer exception at the onClick method inside you adapter because of mSeriesListener is not initialized so add this to SeriesRVAdapter :



            public void setSeriesListener(SeriesListener mSeriesListener) {
            this.mSeriesListener = mSeriesListener;
            }


            and this to CategoriesFragment :



            SeriesRVAdapter myAdapter = new SeriesRVAdapter(getActivity(),seriesDBS);
            myAdapter.setSeriesListener(this);


            and implement the seriesKnowledge method at the CategoriesFragment:



            public void seriesKnowledge(String title,String desc,int thumb){
            }





            share|improve this answer














            You are having a nullpointer exception at the onClick method inside you adapter because of mSeriesListener is not initialized so add this to SeriesRVAdapter :



            public void setSeriesListener(SeriesListener mSeriesListener) {
            this.mSeriesListener = mSeriesListener;
            }


            and this to CategoriesFragment :



            SeriesRVAdapter myAdapter = new SeriesRVAdapter(getActivity(),seriesDBS);
            myAdapter.setSeriesListener(this);


            and implement the seriesKnowledge method at the CategoriesFragment:



            public void seriesKnowledge(String title,String desc,int thumb){
            }






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 27 '18 at 15:55

























            answered Dec 27 '18 at 15:40









            Oussema Aroua

            4,02611634




            4,02611634












            • I'm sorry, I don't know exactly where to add it. You said that I should implement it, but if I implement it, will I have to delete the other parties? Normally I wrote as a private message, but I am not able to understand the operation on the site so I answer again here. Can we contact your twitter if I can't solve it again?
              – Furkan
              Dec 27 '18 at 15:52










            • I updated my answer I hope it's clear now, you don't need to delete anything
              – Oussema Aroua
              Dec 27 '18 at 15:56










            • Application shutdown problem is solved but does not intent. The application does not close at the moment but my button does not make any intent when I click.
              – Furkan
              Dec 27 '18 at 16:08










            • i cant solve the problem @Oussema Aroua
              – Furkan
              Dec 28 '18 at 23:42




















            • I'm sorry, I don't know exactly where to add it. You said that I should implement it, but if I implement it, will I have to delete the other parties? Normally I wrote as a private message, but I am not able to understand the operation on the site so I answer again here. Can we contact your twitter if I can't solve it again?
              – Furkan
              Dec 27 '18 at 15:52










            • I updated my answer I hope it's clear now, you don't need to delete anything
              – Oussema Aroua
              Dec 27 '18 at 15:56










            • Application shutdown problem is solved but does not intent. The application does not close at the moment but my button does not make any intent when I click.
              – Furkan
              Dec 27 '18 at 16:08










            • i cant solve the problem @Oussema Aroua
              – Furkan
              Dec 28 '18 at 23:42


















            I'm sorry, I don't know exactly where to add it. You said that I should implement it, but if I implement it, will I have to delete the other parties? Normally I wrote as a private message, but I am not able to understand the operation on the site so I answer again here. Can we contact your twitter if I can't solve it again?
            – Furkan
            Dec 27 '18 at 15:52




            I'm sorry, I don't know exactly where to add it. You said that I should implement it, but if I implement it, will I have to delete the other parties? Normally I wrote as a private message, but I am not able to understand the operation on the site so I answer again here. Can we contact your twitter if I can't solve it again?
            – Furkan
            Dec 27 '18 at 15:52












            I updated my answer I hope it's clear now, you don't need to delete anything
            – Oussema Aroua
            Dec 27 '18 at 15:56




            I updated my answer I hope it's clear now, you don't need to delete anything
            – Oussema Aroua
            Dec 27 '18 at 15:56












            Application shutdown problem is solved but does not intent. The application does not close at the moment but my button does not make any intent when I click.
            – Furkan
            Dec 27 '18 at 16:08




            Application shutdown problem is solved but does not intent. The application does not close at the moment but my button does not make any intent when I click.
            – Furkan
            Dec 27 '18 at 16:08












            i cant solve the problem @Oussema Aroua
            – Furkan
            Dec 28 '18 at 23:42






            i cant solve the problem @Oussema Aroua
            – Furkan
            Dec 28 '18 at 23:42















            0














            I still haven't figured out the problem yet. I've solved the problem of stopping the application with the comments given by @OussemaAroua , but this time it was not intent. I tried through another solution from another site did intent but didn't pass my data. How can I solve the problem?






            share|improve this answer








            New contributor




            Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.























              0














              I still haven't figured out the problem yet. I've solved the problem of stopping the application with the comments given by @OussemaAroua , but this time it was not intent. I tried through another solution from another site did intent but didn't pass my data. How can I solve the problem?






              share|improve this answer








              New contributor




              Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.





















                0












                0








                0






                I still haven't figured out the problem yet. I've solved the problem of stopping the application with the comments given by @OussemaAroua , but this time it was not intent. I tried through another solution from another site did intent but didn't pass my data. How can I solve the problem?






                share|improve this answer








                New contributor




                Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                I still haven't figured out the problem yet. I've solved the problem of stopping the application with the comments given by @OussemaAroua , but this time it was not intent. I tried through another solution from another site did intent but didn't pass my data. How can I solve the problem?







                share|improve this answer








                New contributor




                Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer






                New contributor




                Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered Dec 28 '18 at 13:52









                Furkan

                11




                11




                New contributor




                Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Furkan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






















                    Furkan is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    Furkan is a new contributor. Be nice, and check out our Code of Conduct.













                    Furkan is a new contributor. Be nice, and check out our Code of Conduct.












                    Furkan is a new contributor. Be nice, and check out our Code of Conduct.
















                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53947335%2fhow-to-intent-from-recyclerview-to-fragment%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Angular Downloading a file using contenturl with Basic Authentication

                    Monofisismo

                    Olmecas