我有三个Fragments
(FragmentActivity
带viewPager
)。我想添加一个刷新按钮,它基本上会删除所有片段并重新加载为新的。每个Fragment
都有 ListView
。这是不恰当的黑客攻击还是我应该刷新ListViews
?(如果是这样,我不确定如何访问ListViews
from Fragments
?FragmentActivity
)
这是我设置片段的方式:
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
mSectionsPagerAdapter = new SectionsPagerAdapter(
getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.viewpager);
mViewPager.setAdapter(mSectionsPagerAdapter);
mViewPager.setOffscreenPageLimit(3);
mViewPager
.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
actionBar.addTab(actionBar.newTab()
.setText(mSectionsPagerAdapter.getPageTitle(i))
.setTabListener(this));
}