Saturday, February 5, 2011

Re: [android-developers] Completely disable Soft Keyboard from EditText

Can I first ask, what are you trying to accomplish?  What is the purpose of having an editable text view if the user can't actually put text into it?

On Tue, Feb 1, 2011 at 10:29 AM, zenperttu <perttu.salo@gmail.com> wrote:
Hi!

I would like a way to turn off showing the current soft keyboard for
an EditText. I have a custom View that provides the soft input needed
for an EditText, so on every occasion (on click, on focus change, on
touch...) when by default the soft keyboard would be shown, I want it
NOT to be shown.

The closest things I found are
http://groups.google.com/group/android-developers/browse_thread/thread/2565bc51c5ff4dbb

and

http://stackoverflow.com/questions/1109022/how-to-close-hide-the-android-soft-keyboard

and

http://stackoverflow.com/questions/1109022/how-to-close-hide-the-android-soft-keyboard

These however do not work for me.

The solution suggested in the latter

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


for example works only after the EditText has been selected by the
user and is already accepting input and so the soft keyboard is
already on the screen. I want it never to appear.


I can try to implicitly set all of the onFocusChangeListener,
onTouchListener, onClickListener  to do

public void onSomeActionListener(View v) {

InputMethodManager imm = (InputMethodManager)
context.getSystemService(Context.INPUT_METHOD_SERVICE);
                       if (imm.isActive(v)) {
                               imm.toggleSoftInput(0,0);
                       }
}


However, this is really not a nice solution because

1) the soft keyboard is first called and shown so that it briefly
flashes on the screen before disappearing

2) I can't by trial and error try to find all the different ways user
could cause soft keyboard to be shown and override all corresponding
methods


Thanks for your help!

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



--
Dianne Hackborn
Android framework engineer
hackbod@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

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

No comments:

Post a Comment