Wednesday, June 30, 2010

[android-developers] Re: How to dismiss the soft keyboard

Thanks!

I used:

txtQuery.setOnKeyListener(this);
...
...
public boolean onKey(View arg0, int keyCode, KeyEvent event)
{
if ((event.getAction() == KeyEvent.ACTION_UP) && (keyCode ==
KeyEvent.KEYCODE_ENTER))
{
doSearch();
...
...

And used the answer from the previous post to hide the keyboard

Bryan

On Jun 29, 8:17 am, jamesc <jame...@gmail.com> wrote:
> Have a look at View.onKeyUp() or View.onKeyDown() to handle to
> keypresses.
>
> As for the IME, take a look at this recent post:
>
> http://groups.google.com/group/android-developers/browse_thread/threa...
>
> On Jun 28, 8:23 am, skooter500 <skooter...@gmail.com> wrote:
>
> > Hi
>
> > I have a TextView and a search button on an activity. When I press the
> > enter key, I want to do something and then dismiss the soft keyboard
> > programatically. I have set the TextView to be single line by using:
>
> > android:singleLine="true", which moves the focus to the next component
> > when you press the enter key
>
> > 1. How do I trap the enter key? A TextWatcher? An OnKeyListener?
>
> > 2. How do I dismiss the soft keyboard programatically?
>
> > Thanks!
>
> > Bryan
>
>

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