我之前使用过 Fragment,所以我有 5 个 Fragment 对应于 ViewPagerIndicator 中的 5 个选项卡,但是如何填充每个选项卡?这是我拥有的片段示例:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
viewta = inflater.inflate(R.layout.agridviewxml, container, false);
}
这是我的 ViewPagerIndicator 的工作方式:
private static final String[] CONTENT = new String[] { "Samsung", "HTC",
"LG", "Sony", "Search" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_tabs);
FragmentPagerAdapter adapter = new GoogleMusicAdapter(
getSupportFragmentManager());
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(adapter);
TabPageIndicator indicator = (TabPageIndicator) findViewById(R.id.indicator);
indicator.setViewPager(pager);
}
class GoogleMusicAdapter extends FragmentPagerAdapter {
public GoogleMusicAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return TestFragment.newInstance(CONTENT[position % CONTENT.length]);
}
@Override
public CharSequence getPageTitle(int position) {
return CONTENT[position % CONTENT.length].toUpperCase();
}
@Override
public int getCount() {
return CONTENT.length;
}
}
}
有什么想法或建议吗??多谢
每个选项卡都是空的,我想用数据填充它(填充它):