2

What I want to do is this: I have an EditText and when the user click on it, the user can move the caret position, same as the EditText, but without showing the keyboard.

I've tried with setInputType(0); and it hides completly the keyboard but the cursor doesn't appears.

Is there any way to do this?

Thank's

cbedoya
  • 171
  • 2
  • 12

3 Answers3

4

The following tricks works for me. Caret and soft keyboard both active onTouch event of editText. So Call touch event and then hide the keyboard manually.

myEditText.setOnTouchListener(new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        final boolean ret = dialerNumber.onTouchEvent(event);
        final InputMethodManager imm = ((InputMethodManager) myContext
                .getSystemService(Context.INPUT_METHOD_SERVICE));
        try{
            imm.hideSoftInputFromWindow(myEditText.getApplicationWindowToken(), 0);
        }catch(Exception e){
            e.printStackTrace();
        }
        return ret;
});
shantanu
  • 2,408
  • 2
  • 26
  • 56
0

I haven't tried suppressing the keyboard altogether, but I have hidden the soft keyboard manually before using the InputMethodManager.hideSoftInputFromWindow method.

Rich
  • 36,270
  • 31
  • 115
  • 154
  • Yeah that works hidding the keyboard, but it hides the cursor button. What I want to do is to have the EditText, and when is clicked, show the little cursor that allows to move the caret in the text, but I think is not possible to do that – cbedoya Jan 17 '12 at 08:15
0

Does this work?

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
Anthony
  • 12,177
  • 9
  • 69
  • 105
Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
  • well it hides the keyboard, but i want to keep the cursor button under the EditText, but I don't know if that is possible – cbedoya Jan 17 '12 at 08:13