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. Oot: paging androiders lampung.

Ada gak yah member id-android yang di lampung? Klo ada tolong absen di sini 
donk...

Mau bikin mirink, sekaligus minta bantuan untuk root spica punya temen :)



Thanks,


Warm regards,




~ Android is the best ~

-- 
===============
"

2. Revert

Kok di android banyak pakai kata revert? Maksudnya apa...

syd
ptk
snet form granimauss a10

-- 
===============
"

3. reading Gallery 3D cache

4. Adobe Camp Indonesia

5. Adapter fetches and parses RSS feed to get data - best practice?

6. Decryption key that only works with your phone number?

7. How to deal with the SQLite resource that is too large?