我正在尝试将默认主题设置为自定义对话框但无法执行此操作。我已将默认的“THEME_DEVICE_DEFAULT_LIGHT”设置为我的alertDialogs,我想在自定义对话框中使用相同的主题。
我可以使用以下代码设置其他主题,但我无法使用DEVICE_DEFAULT_LIGHT。
新的ContextThemeWrapper(context,R.style.MyTheme);
public static Dialog createSeatAssignmentDialog(final Context context, final SeatAssignmentCallback callback) {
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.assign_seat_dialog);
dialog.setTitle(R.string.assign_seat_dialog_title);
dialog.setOnKeyListener(DIALOG_ON_KEY_LISTENER);
new ContextThemeWrapper(context, R.style.Theme_AppCompat_Light_Dialog);
final EditText seat = (EditText) dialog.findViewById(R.id.seat_data);
final Button clearSeatData = (Button) dialog.findViewById(R.id.clear_seat_data);
final Button assignSeat = (Button) dialog.findViewById(R.id.assign_seat);
final Button cancel = (Button) dialog.findViewById(R.id.cancel_seat);
seat.setText(callback.getSeatNumber());
clearSeatData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
seat.setText("");
}
});
assignSeat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.cancel();
}
});
final SeatDialogHandler dialogEventHandler = new SeatDialogHandler(callback, seat);
dialog.setOnCancelListener(dialogEventHandler);
dialog.setOnDismissListener(dialogEventHandler);
dialog.setOnShowListener(dialogEventHandler);
dialog.show();
return dialog;
}
答案 0 :(得分:0)
像这样使用
Dialog dialog = new Dialog(context,android.R.style.Theme_DeviceDefault_Light);