Defining EditText imeOptions when using InputMethodManager.showSoftInput(View, int, ResultReceiver)

Posted by TuomasR on Stack Overflow See other posts from Stack Overflow or by TuomasR
Published on 2010-10-13T12:26:20Z Indexed on 2014/08/24 10:21 UTC
Read the original article Hit count: 148

Filed under:

In my application I have a custom view which requires some text input. As the view in itself doesn't contain any actual views (it's a Surface with custom drawing being done), I have a FrameLayout which contains the custom view and underneath it an EditText -view. When the user does a specific action, the custom view is hidden and the EditText takes over for user input. This works fine, but android:imeOptions seem to be ignored for this view. I'm currently doing this:

    InputMethodManager inputMethodManager = (InputMethodManager)parent.getSystemService(Context.INPUT_METHOD_SERVICE);
    EditText t = (EditText)parent.findViewById(R.id.DummyEditor);
    t.setImeOptions(EditorInfo.IME_ACTION_DONE);
    inputMethodManager.showSoftInput(t, 0, new ResultReceiver(mHandler) {
      @Override
      protected void onReceiveResult(
            int resultCode, Bundle resultData) {
               // We're done
            System.out.println("Editing done : " +
              ((EditText)parent.findViewById(R.id.DummyEditor)).getText());
            }
      }
    );

It seems that the setImeOptions(EditorInfo.IME_ACTION_DONE) has no effect. I've also tried adding the option to the layout XML with android:imeOptions="actionDone". No help.

Any ideas?

© Stack Overflow or respective owner

Related posts about android