请告诉我如何使用 Datapicker 对话框在 Datapicker 中仅显示月份和年份
private DatePickerDialog.OnDateSetListener mDateSetListener2 = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
try {
Log.e("","myear"+mYear_1+","+"myear"+mMonth_1+","+mDay_1);
Field f[] = mDateSetListener2.getClass().getDeclaredFields();
for (Field field : f) {
if (field.getName().equals("mDatePicker")) {
field.setAccessible(true);
Object dayPicker = new Object();
dayPicker = field.get(mDateSetListener2);
((View) dayPicker).setVisibility(View.GONE);
}
}
} catch (SecurityException e) {
Log.e("ERROR", e.getMessage());
}
catch (IllegalArgumentException e) {
Log.e("ERROR", e.getMessage());
} catch (IllegalAccessException e) {
Log.e("ERROR", e.getMessage());
}
}
};