Tuesday, February 1, 2011

[android-developers] InputMethodManager and it's active View

I would like to know if there is any way to determine and set what
view is active to the InputMethodManger. I have a scenario where
attempting to show the soft keyboard is always returning false. Asking
for imm.isActive() returns true so some view is active... but I have
not been able to determine which it is.

The scenario I have is an AlertDialog containing a single EditText
view. In my main activity, I click a button that launches the Dialog.
I have an onFocusChangeListenter set on the EditText which checks when
it receives focus and based on log messages it is receiving focus
successfully when the dialog is displayed. However, I am running
several checks inside if(hasFocus) and the all return false. Here are
some of the tests I'm running during onFocusChange(View v, boolean
hasFocus).

imm is the InputMethodManager called with the usual convention of
(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE).

((EditText)v).isInputMethodTarget() returns false
imm.isActive(v) returns false
imm.isActive() returns true, so some view is active for input...
imm.showSoftInput(v, 0) does not show the view and returns false.
imm.showSoftInput(mAlertDialog.getListView(), 0) also returns false,
thinking possibly the ListView for the dialog was the view which was
active, though it is not.

I'm hoping someone might be able to steer me in the right direction. I
HAVE been able to show the keyboard by getting the Window, then
IBinder WindowToken and passing that to setSoftInputMode, but then it
behaves erratically afterward.

Thanks everyone,
Jeremiah

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate