在我的应用中,我可以看到这种类型的DatePickler
但我想使用这种类型的风格,
不要考虑照片中的颜色,我只需要改变形状。
在此材料网页中可以找到我需要的更多图片类型的DatePickler:
答案 0 :(得分:0)
您可以使用此链接。
http://www.android-examples.com/change-datepickerdialog-theme-in-android-using-dialogfragment/
DatePicker的DialogFragment:
public static class DatePickerDialogTheme extends DialogFragment implements DatePickerDialog.OnDateSetListener{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState){
final Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
//for DatePicker with diffrent style
DatePickerDialog datepickerdialog = new DatePickerDialog(getActivity(),
AlertDialog.THEME_DEVICE_DEFAULT_DARK,this,year,month,day);
return datepickerdialog;
}
public void onDateSet(DatePicker view, int year, int month, int day){
TextView textview = (TextView)getActivity().findViewById(R.id.textView1);
textview.setText(day + ":" + (month+1) + ":" + year);
}
}
在按钮上打开DatePicker点击:
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
DialogFragment dialogfragment = new DatePickerDialogTheme();
dialogfragment.show(getFragmentManager(), "Theme");
}
});
代码与您在该链接上看到的相同
希望这会对你有帮助......