此应用使用卡片视图列表项并连接firebase实时数据库(JSON文件)
我的问题是,在新添加的数据(图像)移到列表底部之后,更新数据库。我想在顶部获取新的添加数据。如何获得
public class WallpapersAdapter extends RecyclerView.Adapter<WallpapersAdapter.WallpaperViewHolder> {
private Context mCtx;
private List<Wallpaper> wallpaperList;
public WallpapersAdapter(Context mCtx, List<Wallpaper> wallpaperList) {
this.mCtx = mCtx;
this.wallpaperList = wallpaperList;
}
@Override
public WallpaperViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mCtx).inflate(R.layout.recyclerview_wallpapers, parent, false);
return new WallpaperViewHolder(view);
}
@Override
public void onBindViewHolder( WallpaperViewHolder holder, int position) {
if (position == getItemCount() - 1){
Wallpaper w = wallpaperList.get(position);
holder.textView.setText(w.title);
Glide.with(mCtx)
.load(w.url)
.into(holder.imageView);
if (w.isFavourite) {
holder.checkBoxFav.setChecked(true);
}
}
}
请帮助我...