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. Unit Test Build Problems

I just switched the way my Android project is being built and non of
my unit tests work any more...I get errors like

WARN/dalvikvm(575): VFY: unable to resolve static field X in .....
WARN/dalvikvm(575): VFY: unable to find class referenced in signature

These errors only come from my Unit Tests, where classes defined in it
can't even see other classes defined in the unit test.

Before each project had it's own directory with copies of the 3rd
party jar files. I've read around that Dex does weird things with
references but haven't been able to figure out how to fix this
problem. Is there a better way to do this? I would love to see an
example of a large Android workspace where there are multiple
projects, jar references, etc...

Is it possible to fix this with an Order/Export tweak ?

The project is structured like this:

    * Eclipse Workspace (PROJECT_HOME classpath variable)
    * lib
          o 3rd-party jars
          o android.jar
    * Java Project A
          o Looks in PROJECT_HOME
    * Java Project B
          o Looks in PROJECT_HOME
          o Depends on project A
    * Android Project
          o Depends on A & B
          o Looks in PROJECT_HOME
    * Android Test Project
          o Depends on A , B, Android Project
          o Looks in PROJECT_HOME

-- 

2. Hello Android Lovers

LOL... I love the Droid Vader theme.. :D
kapan nih kloteran? :P


2010/3/8 Andry <andrym...@gmail.com>

> 

3. System kills my service even no other resource consuming application is running

4. Overriding MediaPlayer Java Interface

5. Accessing the microphone

6. (WTA) About app2sd

7. Plans for Change (Was: Petition: Google, please improve the Android Market.)