大家好,
viewpager有时会在浏览文章时卡住 这是代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
Preferences.applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.detail);
feed = (RSSFeed) getIntent().getExtras().get("feed");
pos = getIntent().getExtras().getInt("pos");
adapter = new DescAdapter(getSupportFragmentManager());
pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(adapter);
pager.setCurrentItem(pos);
}
public class DescAdapter extends FragmentStatePagerAdapter {
public DescAdapter(FragmentManager fm) {
super(fm);
}
@Override
public int getCount() {
return feed.getItemCount();
}
@Override
public Fragment getItem(int position) {
ArticleFragment frag = new ArticleFragment();
Bundle bundle = new Bundle();
bundle.putSerializable("feed", feed);
bundle.putInt("pos", position);
frag.setArguments(bundle);
return frag;
}
}
如果您需要更多代码详细信息,则源代码在此处
https://github.com/enricocid/lffl-feed-reader
感谢您的回复
答案 0 :(得分:2)
尝试adapter = new DescAdapter(getChildFragmentManager());