我有一个datepicker dialogfragment的代码
public class DatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
// Create a new instance of DatePickerDialog and return it
return new DatePickerDialog(getActivity(), this, year, month, day);
}
public void onDateSet(DatePicker view, int year, int month, int day) {
// Do something with the date chosen by the user
}
}
我正在运行它:
DialogFragment newFragment = new DatePickerFragment();
newFragment.show(getFragmentManager(), "datePicker");
这给了我这个对话框:
当我希望它给我这样的东西时:
如何以编程方式或通过xml更改主题?我更喜欢xml所以代码较少,但我不介意......
谢谢
答案 0 :(得分:6)
Datepicker
构造函数接受一个Theme作为参数:
DatePickerDialog(Context context, int theme, this, int year, int monthOfYear, int dayOfMonth);
所以主题参数是:
android.R.style.Theme_Holo_Light_Dialog_NoActionBar
编辑:我认为您正在寻找的是:
public static final int Theme_Holo_Dialog_NoActionBar = 16973937;