I Created class named Popupdialog which extends DialogFragment
. So there is a recyclerview and adapter in that Popupdialog class.but when I am calling ((MyRecyclerViewforsmallcardincart)adapter).getmDataset();
from the activity ,I am getting NullpointerException
.I know that the adapter is not going to the DialogFragment
instead its uses its own adapter.How to overcome from this NullpointerException
.
adapter in the DialogFragment
adapter=new MyRecyclerViewforsmallcardincart(activity,data);
recyclerView.setAdapter(adapter);
Error part of the activity
dataset=((MyRecyclerViewforsmallcardincart)adapter).getmDataset();
int o=((MyRecyclerViewforsmallcardincart)adapter).getdatasize();
actually the problem is that the activity and dialog fragment had individual adapter. how can I able to pass the adapter to Dialog fragment?
FragmentManager fm = getFragmentManager();
PopupDialog dialogFragment = new PopupDialog();
dialogFragment.setArguments(args);
dialogFragment.show(fm, "Color picker")
this is what I used to call DialogFragment
.Thanks in advance