,双击编辑文本然后datepicker对话显示。如何在单击时显示它

时间:2017-03-23 17:26:41

标签: android

editdate.setOnClickListener( new View.`OnClickListener`() {
           @Override
           public void onClick(View v) {
               Calendar mcurrentDate = Calendar.getInstance();
               int mYear = mcurrentDate.get(Calendar.YEAR);
               int mMonth = mcurrentDate.get(Calendar.MONTH);
               int mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH);
               DatePickerDialog mDatePicker;
               mDatePicker = new DatePickerDialog(CreatNotes.this, new DatePickerDialog.OnDateSetListener() {
                   public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
                       // TODO Auto-generated method stub
                    /*      Your code   to get date and time    */
                   //,    selectedmonth = selectedmonth + 1;
                      editdate.setText("" + selectedday + "/" + selectedmonth + "/" + selectedyear);
                   }
               }, mYear, mMonth, mDay);
             //  mDatePicker.setTitle("Select Date");
               mDatePicker.show();

           }
       } );``

3 个答案:

答案 0 :(得分:1)

使用此,

editdate.setFocusable(false);
editdate.setCursorVisible(false);
editdate.setKeyListener(null);

答案 1 :(得分:0)

尝试添加:

android:focusableInTouchMode="false"

给你edittext xml代码

答案 2 :(得分:0)

android:focusable="false"添加到您的EditText