我有一个活动,我有两个日期选择器,首先我用这些语句初始化它们
public class birthDate extends Activity{
Calendar c = Calendar.getInstance();
int currentYear = c.get(Calendar.YEAR);
int currentMonth = c.get(Calendar.MONTH);
int currentDay = c.get(Calendar.DAY_OF_MONTH);
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.birthdate);
DatePicker birthDayDatePicker,periodDatePicker;
birthDayDatePicker = (DatePicker)findViewById(R.id.DatePickerBirthDay);
periodDatePicker = (DatePicker)findViewById(R.id.DatePickerPeriod);
periodDatePicker.init(currentYear, currentMonth, currentDay, new OnDateChangedListener()
{
@Override
public void onDateChanged(DatePicker arg0, int arg1, int arg2,int arg3) {
// TODO Auto-generated method stub
birthDateCalculations();
}
});
birthDayDatePicker.init(currentYear, currentMonth, currentDay, new OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
periodDateCalculations();
}
});
}}
我意识到那些监听器只发生了一次,就好像我再次单击日期选择器一样,这些语句将不会被应用。我想要一种方法来让监听器在我每次单击日期选择器时都处于活动状态。
提前致谢 !