にnotifyDataSetChanged呼び出しが、私はアダプタを作成し、空のリストを持つクラスを通過した後、リフレッシュしません要素は、アダプタ
public void setItems(Posts newPosts) {
Log.i("mytag", "NewPosts items number in the setItems method: " + Integer.toString(newPosts.items.size()));
posts.items.addAll(newPosts.items);
Log.i("mytag", "Posts items number in the setItems method: " + Integer.toString(posts.items.size()));
posts.profiles.addAll(newPosts.profiles);
posts.groups.addAll(newPosts.groups);
notifyDataSetChanged();
}
そして、これはgetItemCountがどのように見えるかです:ログで
@Override
public int getItemCount() {
Log.i("mytag", "Posts items number in the getitemcount method: " + Integer.toString(posts.items.size()));
return posts.items.size();
}
:
07-15 18:57:41.967 7481-7481/com.ovchinnikovm.android.vktop I/mytag: Posts items number in the getitemcount method: 0
07-15 18:57:41.967 7481-7481/com.ovchinnikovm.android.vktop I/mytag: Posts items number in the getitemcount method: 0
07-15 18:57:42.005 7481-7481/com.ovchinnikovm.android.vktop I/mytag: Posts items number in the getitemcount method: 0
07-15 18:57:42.005 7481-7481/com.ovchinnikovm.android.vktop I/mytag: Posts items number in the getitemcount method: 0
07-15 18:57:42.118 7481-7481/com.ovchinnikovm.android.vktop I/mytag: NewPosts items number in the setItems method: 20
07-15 18:57:42.118 7481-7481/com.ovchinnikovm.android.vktop I/mytag: Posts items number in the setItems method: 20
私はrecyclerviewを正しく更新するにはどうすればよいですか?あなたのアダプタを再初期化してみaddAll()
インスタンス化時にアイテムのリストをアダプタに渡していないか、間違ったリストを更新しているようですが、アダプタのコンストラクタのスニペットをポストしてインスタンス化することができますか? –
@NoelOmondi pastebin.com/fYyHfv4E - アダプターpastebin.com/Q5zskEmm - アクティビティーpastebin.com/ZAsrjHeg - ダガーのモジュール –
これらのファイルを通過しました。空のPOSTアイテムをアダプターに渡しているようですあなたのPostsActivityのsetPosts()メソッドに実際にその中の投稿が含まれている場合 –