0

I want the user to enter data in an EditText using a custom keypad. The custom keypad is integrated to the layout. It is not supposed to pop up when the EditText in question is in focus.

The problem I have is that I can't disable the soft keyboard without disabling the editing properties of the EditText: I want the user to be able to position the cursor for example.

I have tried using the InputMethodManager

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

but it doesn't work at least on some OS versions. The keyboard still pops up when I tap the EditText.

I have also tried setting the input mode:

edtView.setInputType(0)

but then I cannot position a cursor. I could Selection.setSelection(Spannable txt, int index); to position the cursor, but how to know the position the user has touched?

4

1 回答 1

0

我自己从未尝试过,但我唯一想到的是:您是否尝试过将OnEditorActionListener添加到您的 EditText 并在hideSoftInputFromWindow每次获得编辑器操作时调用?

于 2013-05-31T15:55:29.237 回答