开发者

How to switch between tabs in Android?

How do I switch between tabs from within one of the activities that is located inside the tab host? I need to complete the p开发者_如何学Pythonroject by tomorrow. My project involves showing 3 tabs with varying content. So please help anyone.


If you added the tabs as activities you can use this code inside a tab child activity

TabActivity main = (TabActivity) getParent(); // get the main 'TabActivity' from a Child (tab)
TabHost tabHost = main.getTabHost(); // get a handle to the TabHost
tabHost.setCurrentTab(<index>)


You can use Tabhost.setCurrentTab(number) for this purpose


This discussion will help u. In my case GrandPrix's solution helped me.

EDIT:

Go through the follwing links:

Development Guide

Programming Android

Android Development Tutorial (Gigerbread - V 1.3)

Layout Tutorial

Also there will be having some sample codes in the Android SDK. You can find the code under 'samples' folder. You can install the 'APIDemos' sample package to your emulator to get an idea about almost evey part of the android.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜