getsupportfragmentmanager not working in fragment

i'm using DialogFragment ​but the getsupportfragmentmanager  ​not working is shows me an error cannot resolve getsupportfragmentmanager  ​();


 

By      07-Nov-2023    2

Solutions


Nawab

Create a private FragmentActivity Context;

and Override

@Override
public void onAttach(Activity activity) {
    Context=(FragmentActivity) activity;
    super.onAttach(activity);
}

and use as below where you needed

FragmentManager fragManager = Context.getSupportFragmentManager();

 

Your Answer

10042