Cannot Resolve Method 'show(android.support.v4.app.fragmentmanager, Java.lang.string)
For some reason when I try to show a Dialog I get an error from dialog.show(fm, DIALOG_DATE); saying Cannot resolve method 'show(android.support.v4.app.FragmentManager, java.lang.
Solution 1:
To solve this, if you are using android.app.DialogFragment, then use getFragmentManager():
mDateButton.setOnClickListener(newView.OnClickListener() {
publicvoidonClick(View v) {
FragmentManagerfm= getActivity().getFragmentManager();
DatePickerFragmentdialog=newDatePickerFragment();
dialog.show(fm, DIALOG_DATE);
}
});
to use getSupportFragmentManager(), must extend from: android.support.v4.app.DialogFragment.
check your import:
import android.support.v4.app.DialogFragment;
Solution 2:
This solved the problem for me.
publicvoidshowDatePicker() {
DialogFragment newFragment = new DatePickerFragment();
newFragment.show(getFragmentManager(),"datePicker");
}
Post a Comment for "Cannot Resolve Method 'show(android.support.v4.app.fragmentmanager, Java.lang.string)"