我有一个ViewPager,我在其中以编程方式删除视图并将其设置为新页面,有点像这样:
private static class ProfilesPagerAdapter extends FragmentStatePagerAdapter
{
private ArrayList<SherlockFragment> mViews = new ArrayList<SherlockFragment>();
...
}
mProfilesPagerAdapter.mViews.remove(position);
mViewPager.setAdapter(mProfilesPagerAdapter);
mViewPager.setCurrentItem(newPos);
有没有办法可以在要移除的视图上放置动画?
答案 0 :(得分:-1)
我的解决方案是在FragmentPagerAdapter
方法之后复制setCustomAnimations
课程和beginTransaction
:
@Override
public Object instantiateItem(ViewGroup container, int position) {
if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction();
mCurTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
}
...
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction();
mCurTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
}
...
}
的来源