有人用过DatePickDialog吗

Rogin 发布于 2016/05/08 12:17
阅读 180
收藏 0
用的api是6.0的,我这样写
private int year;
    private int month;
    private int day;
    private SimpleDateFormat format;
    private Calendar calendar;
    private String date;
    final DatePickerDialog.OnDateSetListener d = new DatePickerDialog.OnDateSetListener(){
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear,
                              int dayOfMonth) {
            calendar.set(Calendar.YEAR,year);
            calendar.set(Calendar.MONTH,monthOfYear);
            calendar.set(Calendar.DAY_OF_MONTH,dayOfMonth);
            showDate();
        }
    };





format=new SimpleDateFormat("yy/MM/dd");
        picker=(Button)findViewById(R.id.datepicker);
        calendar=Calendar.getInstance();
        year=calendar.get(Calendar.YEAR);
        month=calendar.get(Calendar.MONTH);
        day=calendar.get(Calendar.DAY_OF_MONTH);
        picker.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new DatePickerDialog(MainActivity.this,d,calendar.get(Calendar.YEAR),
                        calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH));
            }
        });


private void showDate()
    {
        date=format.format(calendar.getTime());
        text=(EditText)findViewById(R.id.show);
        text.setText(date);
    }

布局文件就放了一个按钮,然后点上去没反应,应该出来一个dialog的结果没出来



加载中
0
mgic
mgic
show,show,show  没有调用show方法如何弹出对话框?
Rogin
Rogin
好的好的,我现在知道了,谢谢
返回顶部
顶部