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. how to reduce xml parsing time

hi all,
in my application i have to read xml from web-service,
it is working fine, but major problem is it is taking more
time to parse data, though same data is taking less time on
iPhone and Blackberry. i have similar code on blackberry it is
taking less time to parse. is any fast parsing process in Android?
if any body know kindly reply me.
my code simple is as follow.

 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                       DocumentBuilder db = dbf.newDocumentBuilder();
                       doc = db.parse(in);
NodeList nodes = doc.getElementsByTagName("Member");
 if(nodes.getLength() > 0){

                            for (int i = 0; i < nodes.getLength(); i++) {
                                Member mem = new Member();

                                Element memelement = (Element) nodes.item(i);

                                NodeList member =
memelement.getElementsByTagName("MemberID");
                                Element memberText = (Element) member.item(0);
                                String  MemberID =
getCharacterDataFromElement(memberText);
                                mem.setMemberID(MemberID);

                                member = 
memelement.getElementsByTagName("FirstName");
                                memberText = (Element) member.item(0);
        
mem.setFirstName(getCharacterDataFromElement(memberText));

                                member =
memelement.getElementsByTagName("LastName");
                                memberText = (Element) member.item(0);
        
mem.setLastName(getCharacterDataFromElement(memberText));

                                member =
memelement.getElementsByTagName("MailingAddress1");
                                memberText = (Element) member.item(0);
        
mem.setMailingAddress1(getCharacterDataFromElement(memberText));
                                ...
                                ...
                                ...
                                }
Thanks and regards
Syed Imran ali

-- 

2. Developer Console not showing number of apps

Hello,

ps: sorry about my English...


I had published an app and in two days the number of downloads were
update normally.
But since wednesday the numbers are the same, and I know that maaaany
people had download the app.

Anyone knows why?


If there is anyone here that works in google, the app name is "World
DroidCup".

-- 

3. Tiap ganti kartu memori HH langsung restar

4. Asynchronous Http Request

5. content provider, activity.startManagingCursor and simple dao

6. sendWallpaperCommand() behavior changed in 2.2

7. WTcurcol Axis - XL Lampung