Android Drum选择器活动

时间:2012-06-16 05:37:48

标签: android datepicker android-activity

我从this link

找到了DatedrumPicker

我已将它与我的应用程序集成,它在我第一次打开它时效果非常好,但是当我第二次打开它时,它不会在选择器中显示当前日期。

DrumPickerActivity.java中发现,在第一次打开时,它进入onDateChangedListener,但第二次没有。

我不明白听众是如何运作的?

这是活动的代码

public class DrumPickerActivity extends Activity {

String pday; 
Calendar calendar = Calendar.getInstance();
public static Context con;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.dateconversion);
    final TextView date = (TextView) findViewById(R.id.date);
 final String DATE_FORMAT = "%04d"
        +getString(R.string.year)
        +"%02d"
        +getString(R.string.month)
        +"%02d"
        +getString(R.string.day)
        ;
     Resources res= this.getResources();


    final String[] HijrimonthName = res.getStringArray(R.array.Month_ar);


    final int year = calendar.get(Calendar.YEAR);
    final int month = calendar.get(Calendar.MONTH);
    final int day = calendar.get(Calendar.DAY_OF_MONTH);

    final DateDrumPicker dPicker = (DateDrumPicker)    findViewById(R.id.datepicker);

dPicker.setOnDateChangedListener(new OnDateChangedListener() {
 @Override
public void onDateChanged(DatePicker view, int year,
                int monthOfYear, int dayOfMonth) {

 date.setText(String.format(DATE_FORMAT, year, monthOfYear,
                    dayOfMonth));
        }//end onDateChanged

    });
 }

由于

0 个答案:

没有答案