EditText.onKeyUp() doesn't catch all keys

by CG » Sat, 26 Sep 2009 02:10:05 GMT


Sponsored Links
 Dear all,

I'm writing a little dictionary application for Android 1.5, and I'd
like to catch the user's keystrokes in an EditText instance. The
following code recognizes all keys, which are typed in in the Android
emulator:

  new EditText(this) {
    @Override
    public boolean onKeyUp(final int key, final KeyEvent event) {
      Log.i("Key:", Integer.toString(key));
    }
  };

..which is fine! But I open and use the soft keyboard, most input
(except for e.g. the ENTER key) is ignored. Could anyone tell me
what's the best/easiest way to identify and process these user inputs?

Thanks for your attention,
Christian


--~--~---------~--~----~------------~-------~--~----~



EditText.onKeyUp() doesn't catch all keys

by CG » Sun, 27 Sep 2009 00:40:57 GMT


 Dear all,

I'm writing a little dictionary application for Android 1.5, and I'd
like to catch the user's keystrokes in an EditText instance. The
following code recognizes all keys, which are typed in in the Android
emulator:

 new EditText(this) {
   @Override
   public boolean onKeyUp(final int key, final KeyEvent event) {
     Log.i("Key:", Integer.toString(key));
   }
 };

..which is fine! But I open and use the soft keyboard, most input
(except for e.g. the ENTER key) is ignored. Could anyone tell me
what's the best/easiest way to identify and process these user inputs?

Thanks for your attention,
Christian
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


EditText.onKeyUp() doesn't catch all keys

by Dianne Hackborn » Sun, 27 Sep 2009 02:40:34 GMT


 IMEs perform their edits through the InputConnection interface.  Apps should
generally watch for edits on the text view rather than catching key events.






-- 
Dianne Hackborn
Android framework engineer
hack...@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.

--~--~---------~--~----~------------~-------~--~----~



EditText.onKeyUp() doesn't catch all keys

by CG » Wed, 30 Sep 2009 21:44:06 GMT


 


Thanks for the quick answer. This approach looks somewhat different to
the Java Swing architecture, so could you please provide me with some
more information on this topic (..either a concrete solution or texts
on Android's watcher concept/design principle?)

Thanks again,
Christian


--~--~---------~--~----~------------~-------~--~----~



EditText.onKeyUp() doesn't catch all keys

by Hannes Steiger » Sat, 03 Oct 2009 03:43:16 GMT


 > You can look at the java docs for the things in android.text that related to

..seems as if some people are too arrogant to give concrete help?
Sorry, no offense ;)

You can add a TextWatcher to your text field. In your case, this would
look something like:

  EditText in = new EditText(this);
  in.addTextChangedListener(new TextWatcher() {
    public void onTextChanged(CharSequence cs, int s, int b, int c) {
      Log.i("Key:", cs.toString());
    }
    public void afterTextChanged(Editable editable) { }
    public void beforeTextChanged(CharSequence cs, int i, int j, int
k) { }
  });

Best,
Hannes


--~--~---------~--~----~------------~-------~--~----~



EditText.onKeyUp() doesn't catch all keys

by Jason Proctor » Sat, 03 Oct 2009 03:56:57 GMT


 >  > You can look at the java docs for the things in android.text that 

advising people to do a bit of research of their own before 
offloading their issues onto the list is hardly arrogance. nobody was 
born knowing about Android, the experts here put time in to learn 
their knowledge and it's reasonable to expect others to do the same.

this isn't android-writemyappforme :-)

-- 
jason.vp.engineering.particle

--~--~---------~--~----~------------~-------~--~----~



EditText.onKeyUp() doesn't catch all keys

by CG » Sat, 03 Oct 2009 19:25:59 GMT


 Sorry everyone; I didn't want to create any trouble here.
Thanks anyway for the TextWatcher solution; it works fine.








--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Calling all users!

Hello guys,
I am currently with a strong Wireless Telecom company in Dallas, TX.
They have several entry level positions with anyone who has worked on
any projects with Android and/or LiMo.

Please feel free to contact me at melissaca...@worldlink-us.com

Thank you

Melissa Cantu
melissaca...@worldlink-us.com

-- 

2. BE:Display resolution of android

Hi friends,
       I am new to android and I m not having much knowledge about android. 
What is the maximum resolution I can get from android for video and if I want 
to increase resolution what changes I need to do. 

Regards,
Sagar Gajjar

-- 

3. Error with Eclipse

4. Starting a service from top-level launcher

5. Very specific question about Foreground / Background tasks...

6. Could not open Selected VM debug port (8700). [error]

7. Problem with Ubuntu 9.10? Please read!