I have a problem with creating a dialog. It does appear, but its empty inside, just a blank box is shown.
Dialog class:
public class SomeDialog extends DialogFragment{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
builder.setView(inflater.inflate(R.layout.somelayout, null));
return super.onCreateDialog(savedInstanceState);
}
}
In an activity, creating an object and calling show method:
SomeDialog obj = new SomeDialog();
obj.show(getFragmentManager(), "randomtag");
This method is deprecated. androidx.
DialogFragment is a utility class of android development that is used to show a Dialog window, Floating on top of an activity window in an android application.
return super.onCreateDialog(savedInstanceState);
You are returning the parent method. You should return your own . Change to :
return builder.create();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With