我收到错误:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
当我的ErrorDialogFragment正在执行builder.create();
这是我的ErrorDialogFragment代码:
public class ErrorDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
String title = getArguments().getString("title");
String message = getArguments().getString("message");
View dialogView = inflater.inflate(R.layout.dialog_error, null);
TextView tvTitle = (TextView) dialogView.findViewById(R.id.tvTitle);
TextView tvMessage = (TextView) dialogView.findViewById(R.id.tvMessage);
Button btnOk = (Button) dialogView.findViewById(R.id.btnOk);
tvTitle.setText(title);
tvMessage.setText(message);
btnOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
builder.setView(dialogView);
return builder.create();
}
}
调用ErrorDialogFragment的活动会扩展Activity
,我需要全屏显示主题android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"
。并且需要其他主题UI以奇怪的方式工作。
有什么想法吗?
答案 0 :(得分:0)
使用android.app.DialogFragment
代替android.support.v7.app.AlertDialog
。