android how to set hidden keyboard for an edittext

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

Answers


What about

EditText et = (EditText)findViewById(R.id.et);
et.setInputType(InputType.TYPE_NULL);

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" />

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);

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">


Need Your Help

Unconventional use of Iterator to iterate over a collection

java performance for-loop while-loop iterator

I am aware of the conventional iterator creation-usage for a List&lt;String&gt; list as below: