Click a button to go next tab in Android
I have an Android application which is a tab layout and contains 3 tabs. There is a button in the first tab, which when clicked should go to the second tab. Also the second tab contains a back button which when clicked should go to the first tab. How to do this? Actually it should w开发者_运维知识库ork like clicking on the tabs. Please help at the earliest.
TabHost's setCurrentTab() will solve this problem, and you can deal with this in the main TabHost activity. The other activities which represent tabs can use a onclick listener on the button to interact with the setCurrentTab of the activity that contains the TabHost. I will try to post some code up if i find some time, but setCurrentTab() is what you want to use. There are probably more way to do this too, but this is what comes to mind right now.
For this write code in tab click listener.If u click first button then in that cleck listener use code as setCurrentTab(1)
for go the second tab.
精彩评论