Android的 - 在SDK 20 +标签模板刷卡需要帮助 [英] Android - Need help for Tabs+Swipe template in SDK 20

查看:128
本文介绍了Android的 - 在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 that ViewPager. Personally I'd rather use a PagerTabStrip, 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/or DummySectionFragment inner classes of the generated activity. Right now, this is set up to have three pages, each of which is merely a TextView. But, you could have DummySectionFragment inflate a layout instead, and if you are looking for different layouts per tab, you would probably create separate Fragment implementations per layout/tab combination. You would then teach SectionsPagerAdapter 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆