我正在使用datepicker对话框显示dateformat对话框,我想更改datepicker的divders颜色以及如何自定义datepickerdailog为三个蓝色分隔符是单行。我可以自定义datepicker对话框,如第二张图片
我从datepickersdialog获得了这个对话框。
//我正在使用代码来显示datepicker对话框:
公共类MainActivity扩展了Activity {
private EditText txtView;
private String initialDate;
private String initialMonth;
private String initialYear;
private DatePickerDialog dialog = null;
Context context;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = (Button) findViewById(R.id.button1);
txtView = (EditText) findViewById(R.id.textView1);
context = getApplicationContext();
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar dtTxt = null;
String preExistingDate = (String) txtView.getText().toString();
if (preExistingDate != null && !preExistingDate.equals("")) {
StringTokenizer st = new StringTokenizer(preExistingDate,
"/");
System.out.println("datepicker dialog if condition");
initialMonth = st.nextToken();
initialDate = st.nextToken();
initialYear = st.nextToken();
if (dialog == null)
dialog = new DatePickerDialog(v.getContext(),
new PickDate(), Integer.parseInt(initialYear),
Integer.parseInt(initialDate), Integer
.parseInt(initialMonth) - 1);
dialog.updateDate(Integer.parseInt(initialYear),
Integer.parseInt(initialDate),
Integer.parseInt(initialMonth) - 1);
} else {
dtTxt = Calendar.getInstance();
if (dialog == null)
System.out.println("datepicker dialog if condition else part");
dialog = new DatePickerDialog(v.getContext(),
new PickDate(), dtTxt.getTime().getYear(),
dtTxt.getTime().getDay(), dtTxt.getTime()
.getMonth());
dialog.updateDate(dtTxt.getTime().getYear(), dtTxt
.getTime().getDay(), dtTxt.getTime().getMonth());
dialog.setTitle("");
}
dialog.show();
}
});
}
private class PickDate implements DatePickerDialog.OnDateSetListener {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
view.updateDate(year, monthOfYear, dayOfMonth);
txtView.setText(monthOfYear + "/" + dayOfMonth + "/" + year);
dialog.hide();
}
}
//我想像这样更改对话框分隔符: 应该改变蓝色线,我想要完整的线也如下图所示:
答案 0 :(得分:0)
我无法找到内置DatePicker的主题,因此我使用了这个库并构建了自己的库。