xml文件:

<DatePicker
android:
/>

java代码:

TextView textview2;

DatePicker datep;
Calendar calendar=Calendar.getInstance();
/* (非 Javadoc)
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO 自动生成的方法存根
super.onCreate(savedInstanceState);
setContentView(R.layout.n_layout);
datep=(DatePicker)findViewById(R.id.datep);
textview2=(TextView)findViewById(R.id.date);
int year=calendar.get(Calendar.YEAR);
int month=calendar.get(Calendar.MONTH);
int day=calendar.get(Calendar.DAY_OF_MONTH);

datep.init(year, month, day, new OnDateChangedListener(){

@Override
public void onDateChanged(DatePicker datep, int year, int month,
int day) {
// TODO 自动生成的方法存根
textview2.setText("You select date is"+year+"year"+month+"month"+day+"day");
}

});

OK。

相关文章:

  • 2021-06-11
  • 2022-01-02
  • 2021-12-02
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2021-06-07
  • 2021-11-21
猜你喜欢
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
  • 2021-11-01
  • 2022-01-25
相关资源
相似解决方案