user1903985 user1903985 - 9 days ago 6
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{

@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");

Answer
return super.onCreateDialog(savedInstanceState);

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

 return builder.create();
Comments