非常简单直接上代码:
转自:http://blog.sina.com.cn/s/blog_4ac1b5f60102vgnx.html
final EditText et1=(EditText)findViewById(R.id.editText1); final Calendar c = Calendar.getInstance(); et1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DatePickerDialog dialog = new DatePickerDialog(MainActivity.this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { c.set(year, monthOfYear, dayOfMonth); et1.setText(DateFormat.format("yyy-MM-dd", c)); } }, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)); dialog.show(); } });