3

I really like the template for Tabs+Swipe. You know...this one:

enter image description here

The problem is, I do not know where to start after creating that template. How to put a layout into each tab page?

Can we do something like call a Class when the tab is selected? So I can store the view for first tab in Class A then second tab in Class B.

I cannot found any information about this in Google, maybe because it is a new feature from Android SDK?

Thanks

4

2 回答 2

3

如何将布局放入每个标签页?

生成的代码ViewPager在布局文件中创建一个,并将操作栏选项卡连接到其中的页面ViewPager。就我个人而言,我宁愿使用一个PagerTabStrip,或者可能是 ViewPagerIndicator 等价物之一,但他们没有问我...... :-)

无论如何,要填写页面,您需要替换(或完成)生成的活动的SectionsPagerAdapter和/或DummySectionFragment内部类。现在,它被设置为三个页面,每个页面只是一个TextView. 但是,您可以DummySectionFragment改为扩展布局,如果您正在为每个选项卡寻找不同的布局,您可能会Fragment为每个布局/选项卡组合创建单独的实现。然后,您将教SectionsPagerAdapter您想要多少页 ( getCount()) 以及每页使用什么 ( getItem()) 以及每个选项卡标题是什么 ( getPageTitle())。

于 2012-09-10T16:09:15.800 回答
0

您是否可以放置一个在选项卡之间切换活动的示例?上面的例子并不理想。

于 2012-12-19T21:17:33.553 回答