2

In my app i have an editText . If i click on that then it should open the date picker dialog not the keyboard. Its opening date piker but along with keyboard also coming.

(by default keyboard come for editText but i dont want that) I want for this editText keyboard should not visible/ should be hidden.

How can i do that?

I did like this,

   private EditText editDate;
  editDate=(EditText)findViewById(R.id.editDate);

editDate.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(editDate.getWindowToken(), 0);

                 showDialog(DATE_DIALOG_ID);
            }
        });

its not working. Is there any way?

thank you

Jyosna
  • 4,298
  • 12
  • 58
  • 91

4 Answers4

5

What about

EditText et = (EditText)findViewById(R.id.et);
et.setInputType(InputType.TYPE_NULL);
aleph_null
  • 5,708
  • 2
  • 22
  • 37
2

This thing is working. http://developer.android.com/reference/android/view/ViewGroup.html#attr_android:descendantFocusability

<DatePicker
            android:id="@+id/sheduleDatePicker1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:descendantFocusability="blocksDescendants" />
0

try setting this

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

you might have to make it visible again when your date picker resigns, so that your other edit text should receive keyboard..

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
Krishnabhadra
  • 33,632
  • 30
  • 110
  • 164
  • within editText click event i ll give the 1st line. and where i ll put the 2nd line? – Jyosna Oct 29 '11 at 09:57
  • no, its not working. i tried but still keyboard is coming first then date picker – Jyosna Oct 29 '11 at 09:59
  • Have you seen [this](http://stackoverflow.com/questions/1109022/how-to-close-hide-the-android-soft-keyboard) thread and [this](http://code.google.com/p/android/issues/detail?id=7115) issue.. – Krishnabhadra Oct 29 '11 at 10:05
0

In the ActivityLayout xml file change editDate to uneditable. For example, i used this in my xml:

<EditText android:id="@+id/date_EditText"
        android:editable="false"  <---- this is what you want
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:inputType="none" 
        android:layout_weight="2" 
        android:layout_margin="5dp" android:layout_gravity="center_vertical">

jwp
  • 138
  • 6