目前我正在使用本机日期选择器,但我想以只需要月份和年份的方式更改它如何修改我的代码如下
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
// set date picker as current date
return new DatePickerDialog(this, datePickerListener,
year, month,day);
}
return null;
}
private DatePickerDialog.OnDateSetListener datePickerListener
= new DatePickerDialog.OnDateSetListener() {
// when dialog box is closed, below method will be called.
public void onDateSet(DatePicker view, int selectedYear,
int selectedMonth, int selectedDay) {
/* year = selectedYear;
month = selectedMonth;
day = selectedDay;*/
mynewYear=selectedYear;
myNewMonth=selectedMonth;
myNewDay=selectedDay;
try {
checkDate();
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/*time_date_TV.setText(new StringBuilder()
.append(myNewMonth + 1).append("/")
.append(myNewDay ).append("/").append(mynewYear));
*/
}
};
我只是想隐藏日期部分任何帮助都将非常感谢