I've implemented a custom DialogFragment which I'm showing it on a RatingBar rating listener event in my postReviewFragment, I want to set my RatingBar rating back to 0 when the dialog is dismissed by the user.
Searching on SO I've come across these threads but the solutions doesn't seem to work for me :
Can't use onDismiss() when using custom dialogs
What I've tried so far using above threads :
Implementing DialogInterface.OnDismissListener
on the postReviewFragment and overriding onDismiss()
method
@Override
public void onDismiss(final DialogInterface dialog) {
userRating.setRating(0);
}
Also in the DialogFragment I've overide the onDismiss()
method
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
final Fragment parentFragment = getParentFragment();
if (parentFragment instanceof DialogInterface.OnDismissListener) {
((DialogInterface.OnDismissListener) parentFragment).onDismiss(dialog);
}
}
But still the onDismiss()
method does not fire up when the dialogFragment is dismissed, what am I doing wrong?