views:

25

answers:

1

I have created games with 3 tabs and one of the tab is the game using the onKeyDown (KEYCODE_DPAD_LEFT and KEYCODE_DPAD_RIGHT) to control the game. It is working fine if there is no tab. But now with the tab, the KEYCODE_DPAD_LEFT and KEYCODE_DPAD_RIGHT are actually controlling the tab movement instead of the game.

May I know how to let the KEYCODE_DPAD_LEFT and KEYCODE_DPAD_RIGHT is referred to the game and not the tab?

Thanks.

A: 

I am assuming you are using TabFactory and/or Intents to create the Tabs. You need to write event handling (onKeyDown) for each of child-activities to create actions based on the KeyDown keys.

If you want the child-activities to control tab selection you will have to get access to the parent activity, by using this.getParent() in each of the child-activities.

Using the parent you can control the TabHost: parent,mTabHost.setCurrentTab(index)

Hope this helps.

Sameer Segal