What you need is an OnKeyListener and not a KeyListener.

On Jan 28, 6:04 pm, Dan <danscott0...@gmail.com> wrote:
> Hi,
>
> I'm trying to setup aKeyListeneron an EditText widget. My code is as
> follows:
>
> <code>
>         mMsgToSend.setKeyListener(newKeyListener()
>         {
>                         @Override public boolean onKeyDown(View view, 
> Editable arg1, int
> KeyCode, KeyEvent event)
>                         {
>                                 boolean bReturn = false;
>
>                                 if (KeyCode == KeyEvent.KEYCODE_ENTER)
>                                 {
>                                         SendMessage();
>
>                                         bReturn = true;
>                                 }
>
>                                 return bReturn;
>                         }
>
>                         @Override public boolean onKeyUp(View view, Editable 
> text, int
> keyCode, KeyEvent event)
>                         {
>                                 return false;
>                         }
>         });
>
> </code>
>
> Where mMsgToSend is my EditText widget. The problem is that whenever I
> implement this code, everything stops showing up in my EditText
> widget. Anything I type does not show up in the widget. When I set a
> break point in my code everything is executing as I would expect it
> to.
>
> If I do not have the code in place, everything shows up in the widget
> as I type. My understanding is that if you want everything to be
> handled normally then you return a "false" from the event handlers
> otherwise you return a "true".
>
> Has anyone else experienced this?
>
> Thanks In Advance,
> Dan
--~--~---------~--~----~------------~-------~--~----~
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-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to