I tried as below at onClick() method of recyelerview.viewholder class.
SampleDialogFragment used in the sample extends DialogFragment.
@Override
public void onClick(View v)
{
SampleDialogFragment df= new SampleDialogFragment();
df.show(v.getContext().getSupportFragmentManager(), "Dialog");
}
I'm facing problem at v.getContext().getSupportFragmentManager()
. I can't call getSupportFragmentManager().
I also tried as below .
@Override
public void onClick(View v)
{
SampleDialogFragment df= new SampleDialogFragment();
SampleActivity activity = new SampleActivity();
df.show(activity.getSupportFragmentManager(), "Dialog");
}
SampleActivity is the activity the recycler view is attached . It shows no error. When I run the app and crash.
The log shows that the activity has destoryed.
Any solution ?