Hi All,

I have a tabhost with the tabwidget on the bottom (not hard to do,
just put the tabcontent above the tabs in the tab xml).  However, I
noticed the order of focus is off (since the tabhost is hardcoded to
be on the top).  I'd like to change 2 things in how the tabhost
handles focus order:

1. change the tabwidget's position in the focus order (to be on
bottom, not top)
2. allow left and right focus commands to change the tabs from
anywhere (not just when the tabwidget is focused)

For #2 above, see HTC's sense toolbars for an example (built into the
hero, such as the albums or people native apps).

I think I can achieve both of these by overriding tabhost's
dispatchKeyEvent (code at bottom), I would just change the current
implementation to handle KEYCODE_DPAD_DOWN instead of KEYCODE_DPAD_UP,
and then add in left and right detection as well.

How can I override JUST this method in the tabhost implementation?
I'm not a Java pro, so this could be relatively simple and I'm just
clueless how to do it :)

Thanks much!


--------------------------------------------------------------------------------------
    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        final boolean handled = super.dispatchKeyEvent(event);

        // unhandled key ups change focus to tab indicator for
embedded activities
        // when there is nothing that will take focus from default
focus searching
        if (!handled
                && (event.getAction() == KeyEvent.ACTION_DOWN)
                && (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_UP)
                && (mCurrentView.isRootNamespace())
                && (mCurrentView.hasFocus())
                && (mCurrentView.findFocus().focusSearch
(View.FOCUS_UP) == null)) {
            mTabWidget.getChildAt(mCurrentTab).requestFocus();
            playSoundEffect(SoundEffectConstants.NAVIGATION_UP);
            return true;
        }
        return handled;
    }
-- 
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