我需要在日期选择器对话框中显示出生日期值。目的是,用户可以更新他的出生值数据。这里我的问题是当我单击文本视图时,它显示日期选择器对话框,但显示错误的月份ie if i text view values is 2/2/1980 (mm/dd/yy) means its show 3/2/1980
。我使用以下代码显示并更新出生日期,
text_DOB.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DialogFragment newFragment = new SelectDateFragment();
newFragment.show(getActivity().getFragmentManager(),
"DatePicker");
}
});
public class SelectDateFragment extends DialogFragment implements
DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
String[] dateSpliting = text_DOB.getText().toString().trim()
.split("/");
// Here i return the date, month and year values which is in the textview
return new DatePickerDialog(getActivity(), SelectDateFragment.this,
Integer.parseInt(dateSpliting[2]),
Integer.parseInt(dateSpliting[1]),
Integer.parseInt(dateSpliting[0]));
}
public void onDateSet(DatePicker view, int yy, int mm, int dd) {
text_DOB.setText(new StringBuilder().append(mm + 1).append("/")
.append(dd).append("/").append(yy).append(" "));
view.updateDate(yy, mm + 1, dd);
}
}
我找不到问题,如何在日期选择器中显示 textview 日期。