ViewPager中的片段有一個等效的方法,如OnPageSelected()
或OnPageShow()
?特定頁面顯示時,我應該做些什麼?片段在ViewPager OnPageSelected()或OnPageShow()?
我設置onPageScrolled()
每個片段頁適配器的隱藏狀態,我不知道爲什麼onHiddenChanged(
)不會被調用?
//在PageAdapter(延伸FragmentPagerAdapter)
public void onHiddenChanged(int arg0)
{
for (int i = 0; i < getCount(); i++) {
if (i == arg0) {
mAdapter.getItem(arg0).onHiddenChanged(true);
} else {
mAdapter.getItem(arg0).onHiddenChanged(false);
}
}
}
//在PageActivity(延伸FragmentActivity)
public void onPageSelected(int arg0)
{
mAdapter.onHiddenChanged(arg0);
}
解決@see這樣的:HTTP://stackoverflow.com/questions/10024739/how-to-determine-when-fragment-becomes-visible- in-viewpager/12523627#12523627 – thecr0w