I have a RecyclerView that loads some data from an API, includes an image URL and some data, and I use networkImageView for a lazy loading image.
@Override public void onResponse(List<Item> response) { mItems.clear(); for (Item item : response) { mItems.add(item); } mAdapter.notifyDataSetChanged(); mSwipeRefreshLayout.setRefreshing(false); }
Here is the implementation for the adapter:
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, final int position) { if (isHeader(position)) { return; }
The problem is when we update in recyclerView, it approaches a very short time at the beginning, which looks strange.
I just used the GridView / ListView, and it worked as I expected. There was no glare.
for RecycleView in onViewCreated of my Fragment :
mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); // use this setting to improve performance if you know that changes // in content do not change the layout size of the RecyclerView mRecyclerView.setHasFixedSize(true); mGridLayoutManager = (GridLayoutManager) mRecyclerView.getLayoutManager(); mGridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return mAdapter.isHeader(position) ? mGridLayoutManager.getSpanCount() : 1; } }); mRecyclerView.setAdapter(mAdapter);
Has anyone encountered such a problem? what could be the reason?
android android-fragments android-recyclerview
Ali Mar 29 '15 at 15:35 2015-03-29 15:35
source share