0
我尝试在完成循环后添加列表中的所有对象。 这是我想添加的适配器中的方法。Android将所有对象添加到循环后列表中
public MusicCustomAdapter(Context context) {
songList = new ArrayList<>();
this.context = context;
}
public void addMoreItem(List<SongRespones.Songs> songList) {
this.songList = songList;
notifyDataSetChanged();
}
这是用我的callResponse改造:
private void getAllSongBySinger() {
songService = ServiceGenerator.createService(SongService.class);
Call<SongRespones> callAllSong = songService.findAllSongBySinger();
callAllSong.enqueue(new Callback<SongRespones>() {
@Override
public void onResponse(Call<SongRespones> call, Response<SongRespones> response) {
List<SongRespones.Songs> listSong;
SongRespones songRespones = response.body();
listSong = songRespones.getSongs();
for (SongRespones.Songs songs : listSong) {
if (songs.getSinger().getId() == getSingerId) {
Log.e(LOG, songs + "");
adapter.addMoreItem(What must I input in here?);
recyclerView.setAdapter(adapter);
}
}
}
@Override
public void onFailure(Call<SongRespones> call, Throwable t) {
t.printStackTrace();
}
});
}
请大家帮帮我:
@santaluThank你这么多,先生,我跟着你,现在它的工作:d – Vichit
很乐意帮助你。你能接受答案吗? – santalu
santalu,是的,我可以 – Vichit