Android的 - 在SDK 20 +标签模板刷卡需要帮助 [英] Android - Need help for Tabs+Swipe template in SDK 20
问题描述
我真的很喜欢的模板选项卡+刷卡。你知道...这一个:
问题是,我不知道从哪里开始创建模板之后。 如何把布局到每个标签页?
我们能不能做这样的事调用类时,标签被选中?因此,我可以存储在B级A级然后第二个选项卡第一个选项卡的看法。
我无法在谷歌找到这个的任何信息,也许是因为它是从Android SDK中的一项新功能?
感谢
如何把布局到每个标签页?
块引用>生成的code创建
ViewPager
在布局文件和电线操作栏标签,以便在该页面ViewPager
。就个人而言,我宁愿使用PagerTabStrip
,或ViewPagerIndicator当量可能之一,但他们没有问我...: - )无论如何,填写页面,则需要更换(或全部)的
SectionsPagerAdapter
和/或DummySectionFragment
内部类生成的活性。眼下,这是设置有三个页面,每个仅仅是一个的TextView
。但是,你可以有DummySectionFragment
充气布局相反,如果你正在寻找每片不同的布局,你可能会创建单独的片段
每布局/标签组合实现。这样,你会教SectionsPagerAdapter
你有多少个页面想要的(getCount将()
)和如何使用的每一页(的getItem()
),以及每个选项卡标题是(getPageTitle()
)。I really like the template for Tabs+Swipe. You know...this one:
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
解决方案How to put a layout into each tab page?
The generated code creates a
ViewPager
in the layout file and wires up action bar tabs to the pages in thatViewPager
. Personally I'd rather use aPagerTabStrip
, or possibly one of the ViewPagerIndicator equivalents, but they didn't ask me... :-)Regardless, to fill in the pages, you need to replace (or complete) the
SectionsPagerAdapter
and/orDummySectionFragment
inner classes of the generated activity. Right now, this is set up to have three pages, each of which is merely aTextView
. But, you could haveDummySectionFragment
inflate a layout instead, and if you are looking for different layouts per tab, you would probably create separateFragment
implementations per layout/tab combination. You would then teachSectionsPagerAdapter
how many pages you want (getCount()
) and what to use for each page (getItem()
) and what each tab caption is (getPageTitle()
).这篇关于Android的 - 在SDK 20 +标签模板刷卡需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!