[英]Android DatePickerDialog Theme
I am using the native DatePickerDialog with this theme Resource.Style.Theme_AppCompat_Light_Dialog_Alert
and I am getting this pop-up ApiLevel 23 and above and when I use AlertDialog.ThemeHoloDark
I get the pop-up like this and it says that it is deprecated. 我正在使用带有主题
Resource.Style.Theme_AppCompat_Light_Dialog_Alert
的本机DatePickerDialog,并且正在获取此弹出窗口ApiLevel 23及更高版本,并且当我使用AlertDialog.ThemeHoloDark
时,将得到这样的弹出窗口,并且它表示已弃用。 below api level 23 I have to support the api level above 15 but I am not able to use the second theme since its deprecated but it is much more user friendly than the new one, how can i use the old theme in my current solution since using it only shows warning and there is no error on using it accross device. 低于api级别23,我必须支持高于15的api级别,但由于第二个主题已被弃用,因此我无法使用,但它比新主题更加用户友好,我如何在当前解决方案中使用旧主题,因为使用它只会显示警告,并且在整个设备上使用它都没有错误。 Would I face any concerns if I keep my code using the deprecated theme?
如果我使用过时的主题保留代码,是否会遇到任何担忧?
Use this in your code it will work for you 在您的代码中使用它会为您工作
// Launch Date Picker Dialog
DatePickerDialog dpd = new DatePickerDialog(MainActivity.this,
new DatePickerDialog.OnDateSetListener() {
final Calendar myCalendar = Calendar.getInstance();
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
// TODO Auto-generated method stub
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
String myFormat = "yyyy-MM-dd"; //In which you need put here
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
// expiry.setText(sdf.format(myCalendar.getTime()));
}
}, mYear, mMonth, mDay);
dpd.getDatePicker().setMinDate(System.currentTimeMillis());
dpd.show();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.