使用刷卡查看和瓷砖地带的Android布局 [英] Android layout using Swipe View and Tile Strip
本文介绍了使用刷卡查看和瓷砖地带的Android布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在做一个新的应用程序,使用刷卡查看+瓷砖地带的布局,但似乎无法弄清楚如何实际加载不同的视图FragmentPagerAdapter的片段?
I'm making a new app, using the "Swipe View + Tile Strip" layout, but can't seem to figure out how to actually load different views into the fragments of the FragmentPagerAdapter?
任何帮助将是巨大的(我还是很新的android开发,这样下去容易;))
Any help on this would be great (I'm still quite new to android development, so go easy ;) )
推荐答案
创建扩展一个类 FragmentPagerAdapter
。
覆盖的getItem()
键,返回不同的片段,每个位置。
Override getItem()
and return a different fragment for each position.
尝试是这样的:
public class MyCustomFPAdapter extends FragmentPagerAdapter{
public MyCustomFPAdapter (FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
if (position == 0) {
return Fragment0.newInstance();
} else if (position == 1) {
return Fragment1.newInstance();
} else if (position == 2) {
return Fragment2.newInstance();
} else if (position == 3) {
return Fragment3.newInstance();
} else {
return DefaultFragment.newInstance();
}
}
}
这篇关于使用刷卡查看和瓷砖地带的Android布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文