user1903985 user1903985 - 7 months ago 61
Android Question

Android DialogFragment is blank

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{

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();, "randomtag");

return super.onCreateDialog(savedInstanceState);

You are returning the parent method. You should return your own . Change to :

 return builder.create();