私はinstagramと同様のアプリを実行します。問題は、私が投稿を表示するためのリサイクラビューを持っているフラグメントである。リサイクラービューの最初の要素はヘッダーで、残りはポストです。一部のユーザーに100以上の投稿があり、問題がある可能性があります。私はそれらをAPIからロードしますが、もちろん一度に読み込むわけではありません。私はページ付けを使用しています - 一つのリクエストに対して6つの投稿。次の部分は、リサイクラビューの最後に到達するとロードされます(私はRecyclerViewScrollListenerを実装しました)。投稿はTYPE_TEXT(テキストのみを含む)またはTYPE_IMAGE(テキスト+画像を含む)のタイプにすることができます。画像はGlideによって読み込まれます。次の問題は、画像の解像度が異なることです。下にスクロールすると、リサイクラビューは「ジャンプ」します。私がたくさんの投稿を読み込んで素早くスクロールすると、画像は再び読み込まれ、リサイクルビューは「ジャンプ」します。そんなことはfb、instagramなどでは起こりません。私が間違っていることは考えられません。多くの要素を含むRecyclerViewは正しく動作しません
リクエストコールバック:これは私のコードです
public void onRequestSuccess(Post[] posts) {
postList.addAll(Arrays.asList(posts));
adapter.notifyItemChanged(adapter.getItemCount() - posts.length - 1); // only last element has separated line
adapter.notifyItemRangeInserted(adapter.getItemCount() - posts.length, posts.length);
}
グライド:
progress.setVisibility(View.VISIBLE);
Glide.with(getContext())
.load(post.getUri())
.asBitmap()
.listener((new HideViewOnSuccess<String, Bitmap>(progress)))
.into(image);
image_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
>
<include
layout="@layout/item_post_header"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/post_top_margin"
android:adjustViewBounds="true"
tools:src="@drawable/profile_placeholder"
android:maxHeight="420dp"
android:background="#FFF"
/>
<ProgressBar
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<View
android:id="@+id/bottom_line"
style="@style/Bar"
android:layout_width="match_parent"
android:layout_height="1dp"
/>
</LinearLayout>
http://stackoverflow.com/questions/41934901/switch-button-in-listview-randomly-changes-役立つ以下のリンクを共有work.We使用スクロール時/ 41935212#41935212 –