我正在尝试获取数据列表。但Firebase数据库提供了更多数据。所以我尝试使用RecyclerView加载更多的数据列表。
我已经完成了获取列表详细信息,但没有任何想法,如何在分页中使用1到10以及接下来的11到20来加载更多?
我的代码是:
public static class ShowDataViewHolder extends RecyclerView.ViewHolder {
private final TextView image_title;
private final ImageView image_url;
private final TextView image_Desc;
private final TextView time_upload;
public ShowDataViewHolder(final View itemView) {
super(itemView);
image_url = (ImageView) itemView.findViewById(R.id.fetch_image);
image_title = (TextView) itemView.findViewById(R.id.fetch_image_title);
image_Desc = (TextView) itemView.findViewById(R.id.fetch_image_Desc);
time_upload = (TextView) itemView.findViewById(R.id.time_upload);
image_delete.setVisibility(View.GONE);
}
private void Image_Title(String title,String desc,String time) {
image_title.setText(title);
image_Desc.setText(desc);
time_upload.setText(time);
}
private void Image_URL(String imagename) {
Glide.with(itemView.getContext())
.load(imagename)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(R.drawable.loading)
.error(R.drawable.imagenotavailable)
.into(image_url);
}
}
and
FirebaseRecyclerAdapter mFirebaseAdapter = new FirebaseRecyclerAdapter<ShowDataItems, ShowDataViewHolder>(ShowDataItems.class, R.layout.show_data_single_item, ShowDataViewHolder.class, myRef) {
public void populateViewHolder(final ShowDataViewHolder viewHolder, final ShowDataItems model, final int position) {
viewHolder.Image_Title(model.getImage_Title(),model.getDescription(),model.getTime_upload());
viewHolder.Image_URL(model.getImage_URL());
loading.setVisibility(View.GONE);
}
};
mLayoutManager = new LinearLayoutManager(MainActivity.this);
mLayoutManager.setReverseLayout(true);
mLayoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setAdapter(mFirebaseAdapter);
}
如何解决这个问题?请给我任何建议?