在android日期選擇器中,我需要更改完成按鈕的背景。如何更改日期選取器在android中完成背景和選擇器背景?
代碼:
private void showDateDialog()
{
Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int monthOfYear = c.get(Calendar.MONTH) + 1;
int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
String currentdate = year+"";
if(monthOfYear<10)
currentdate += "0";
currentdate += (monthOfYear);
if(dayOfMonth<10)
currentdate += "0";
currentdate += dayOfMonth;
currentDate = Integer.parseInt(currentdate);
DatePickerDialog datePickerDialog = new DatePickerDialog(SelectEvent.this, new OnDateSetListener()
{
@Override
public void onDateSet(DatePicker view, int _year, int _monthOfYear,
int _dayOfMonth)
{
String date = _year+"";
if(_monthOfYear+1<10)
date += "0";
date += (_monthOfYear+1);
if(_dayOfMonth<10)
date += "0";
date += _dayOfMonth;
selectedDate = Integer.parseInt(date);
DOB = date;
if(selectedDate >= currentDate)
eventdate.setText(_dayOfMonth+"/"+(_monthOfYear+1)+"/"+_year);
else
{
eventdate.setText("");
showDialog("Please Select Event Date");
//Toast.makeText(context, "Please Select Event Date", Toast.LENGTH_SHORT).show();
}
}
}, year, monthOfYear-1, dayOfMonth);
datePickerDialog.setButton(DatePickerDialog.BUTTON_POSITIVE, "DONE", datePickerDialog);
datePickerDialog.show();
}
如果我用這個代碼,我只得到了默認的日期選擇器,並做簡單更改爲DONE。 但我希望該日期選擇器是https://drive.google.com/file/d/0B2NGqFM-F0bNWGl2VG93OUJpaWM/edit?usp=sharing
請給出一些想法和建議如何在Android中更改該顏色。在這個網站我搜查,但我沒有得到。
感謝&問候 桑卡
嘿,這是不適用我得到空指針異常,如果我刪除,如果條件。如果我寫了,我沒有得到任何改變。 – Navadeep
您是在'datePickerDialog.setButton(...)'後面添加了這段代碼嗎? –
您是否已經完成了它的工作? –