来自Spinner的Android DatePickerDialog

时间:2013-11-10 22:38:45

标签: android dialog datepicker spinner

我正在使用我通过按钮打开的DatePickerDialog。如何在旋转器中打开它们?

 public void chooseDate(View v) {
new DatePickerDialog(Movimenti.this, d,
                      dateAndTime.get(Calendar.YEAR),
                     dateAndTime.get(Calendar.MONTH),
                      dateAndTime.get(Calendar.DAY_OF_MONTH))
  .show();

}     private void updateLabel(){

  mDataScelta.setText(fmtDateAndTime.format(dateAndTime.getTime())); 

}

DatePickerDialog.OnDateSetListener d = new DatePickerDialog.OnDateSetListener(){

public void onDateSet(DatePicker view, int year, int monthOfYear,
                      int dayOfMonth) {
  dateAndTime.set(Calendar.YEAR, year);
  dateAndTime.set(Calendar.MONTH, monthOfYear);
  dateAndTime.set(Calendar.DAY_OF_MONTH, dayOfMonth);
  updateLabel();
}

};

1 个答案:

答案 0 :(得分:0)

spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
        // your code here
    }

    @Override
    public void onNothingSelected(AdapterView<?> parentView) {
        // your code here
    }

});