-1

Hey i currently try to add a DialogFragment to a Fragment. It should open when i click on a TextView:

Fragment:

public class FragmentOneRm extends Fragment {



 @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    myContext = (main_container)this.getActivity();

}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { mTextViewMaxWeight.setOnLongClickListener(new View.OnLongClickListener() {
 //other code         
        @Override
        public boolean onLongClick(View v) {
            DialogWeightConverter dialog = DialogWeightConverter.newInstance();
       // Problem with getFragmentManager() 
            dialog.show(getFragmentManager(), "fragmentDialog");

        }
    });


    return view; 

following error appears: Cannot resolve methode show(android.app.FragmentManager, java.lang.string)

Yes i know this question already excist but the solutions didnt work for me :/

my DialogFragment:

public class DialogWeightConverter extends DialogFragment {

Context mContext;

public DialogWeightConverter() {
    mContext = getActivity();
}


@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    Dialog dialog = builder.create();

    return dialog;
}

public static DialogWeightConverter newInstance() {
    DialogWeightConverter f = new DialogWeightConverter();
    return f;
} }

if you need more code from Project i will add it

thanks for help and greetings

Sebastian
  • 408
  • 1
  • 6
  • 11

1 Answers1

1

Your DialogWeightConverter extends from android.support.v4.app.DialogFragment? Try with getActivity().getSupportFragmentManager()

allo86
  • 946
  • 1
  • 9
  • 23