我有一个连接到ViewPager的TabLayout。我的ViewPager的每一页都是片段。首先,当我点击任何标签时,它会平滑地滚动到该标签并且其相关页面可见但是在对所有标签执行相同的工作后,当我再次点击其中一个标签时,它跳转到该位置我可以没有看到任何动画(平滑滚动),但我仍然可以在页面之间平滑滑动。什么是问题是什么以及如何解决?感谢名单
更新: 片段:
@Override
public void requestContentJsonUpdate() // it is called each time the related tab is selected to download data from server. however it happens only the first time
{
if (!getIsLoaded())
{
requestParametricContentJsonUpdate();
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.fragment_infinity, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.fragment_infinity_recycler_view);
if (recyclerViewAdapter == null)
{
recyclerViewAdapter = new SpecificCategoryFragmentRecyclerAdapter
(mContext, this, SupportsGridAndListArrangement.GRID_VIEW);
}
recyclerView.setAdapter(recyclerViewAdapter);
generateStaggeredGridLayout();
setUpRecyclerViewAnimation();
addInfinityFeature();
return view;
}
适配器:
public SpecificCategoryFragmentRecyclerAdapter(Context context, SpecificCategoryFragment fragment, int viewMode)
{
super(context, viewMode);
specificCategoryFragment = fragment;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i)
{
View view;
if (i == TYPE_ITEM)
{
if (arrangeMode == SupportsGridAndListArrangement.GRID_VIEW)
{
view = LayoutInflater.from(viewGroup.getContext()).inflate
(R.layout.grid_advertisement_layout, null);
}
else
{
view = LayoutInflater.from(viewGroup.getContext()).inflate
(R.layout.list_advertisement_layout, null);
}
return new ItemHolder(view, mContext, arrangeMode);
}
else if (i == TYPE_HEADER)
{
view = LayoutInflater.from(viewGroup.getContext()).inflate
(R.layout.caafe_fragment_header, null);
return new HeaderHolder(view);
}
else
{
view = LayoutInflater.from(viewGroup.getContext()).inflate
(R.layout.subcategory_item_row, null);
return new SubcategoryHolder(view);
}
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int i)
{
((HomeActivity) mContext).runOnUiThread(new Runnable()
{
@Override
public void run()
{
...
}
});
}
@Override
public int getItemViewType(int position)
{
...
}
@Override
public int getItemCount()
{
if (jsonDatabase != null)
{
return jsonDatabase.getCount();
}
else
{
return 0;
}
}
}