Correction: both RIGHT and LEFT actions should return TRUE for the
listener.  Corrected code below:

>                 ImageButton ib;
>                 ib.setOnKeyListener(new OnKeyListener()
>                 {
>                         public boolean onKey(View v, int keyCode, KeyEvent 
> event) {
>                                 switch (keyCode)
>                                 {
>                                         case KeyEvent.KEYCODE_DPAD_RIGHT:
>                                                 f_navSelection++;
>                                                 if 
> (f_navSelection>=f_navBar.getChildCount())
>                                                         f_navSelection=0;
>                                                 
> f_navBar.getChildAt(f_navSelection).requestFocus();
>                                                 Logger.log("Child at 
> "+f_navSelection+" has focus?
> "+f_navBar.getChildAt(f_navSelection).hasFocus());
>                                                 return true;
>                                         case KeyEvent.KEYCODE_DPAD_LEFT:
>                                                 f_navSelection--;
>                                                 if (f_navSelection<0)
>                                                         
> f_navSelection=f_navBar.getChildCount()-1;
>                                                 
> f_navBar.getChildAt(f_navSelection).requestFocus();
>                                                 Logger.log("Child at 
> "+f_navSelection+" has focus?
> "+f_navBar.getChildAt(f_navSelection).hasFocus());
>                                                 return true;
>                                 }
>                                 return false;
>                         }
>                 });
>
> -------------
>
> Logging output (for layout with 3 image buttons):
>
> (press right once)>Child at 0 has focus? true
> >Child at 1 has focus? true
>
> View 2 grabs the focus.
>
> (press right again)>Child at 2 has focus? true
> >Child at 0 has focus? true
>
> View 1 grabs the focus.
--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to