我尝试了一些来自How to change DatePicker dialog color for Android 5.0的建议,但唯一的问题是接下来的两个按钮在编写代码后不可见
public static void showExpenseDate(final Context context, final EditText textView) {
final Calendar calendar = Calendar.getInstance();
int yy = calendar.get(Calendar.YEAR);
int mm = calendar.get(Calendar.MONTH);
int dd = calendar.get(Calendar.DAY_OF_MONTH);
DatePickerDialog datePicker = new DatePickerDialog(context, R.style.DialogTheme, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
//String[] mons = new DateFormatSymbols(Locale.ENGLISH).getShortMonths();
//String mName = mons[monthOfYear];
expense_date = String.valueOf(year) + "-" + String.valueOf((monthOfYear + 1))
+ "-" + String.valueOf(dayOfMonth);
textView.setText(expense_date);
Log.d("djkjiksd", expense_date);
}
}, yy, mm, dd);
datePicker.show();
}
在theme.xml中
<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">@color/light_yellow</item>
</style>
但是按钮的颜色没有出现在UI上。2根据应用程序实现日期选择器主题的解决方案和正确的方法是什么?
1条答案
按热度按时间72qzrwbm1#
将您的theme.xml修改为类似以下内容-