我在创建对话框时遇到问题。它确实出现了,但里面是空的,只显示了一个空白框。
对话类:
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);
}
}
在一个活动中,创建一个对象并调用 show 方法:
SomeDialog obj = new SomeDialog();
obj.show(getFragmentManager(), "randomtag");