开发者

TabActivity and onKeyDown

开发者_运维知识库

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜