用最简单简洁的方式做出目标效果
如果有什么不好的地方希望大佬在评论区指出!
本次练习项目是用一个开源的API做了一个图片APP,滑动到底部会触发加载更多
布局方面
main里面放入一个RecyclerView
创建一个item布局来作为列表,这个布局根据自己的需求来添加,我这里用卡片布局放了一个图片控件
java方面
使用到的依赖
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.android.volley:volley:1.1.1'
创建一个bean类
这个是API那边提供的,然后用插件导入生成的
package com.sakura.testvolley.bean;
import java.util.List;
public class PhotoBean {
private int total;
private int totalHits;
private List<HitsBean> hits;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public int getTotalHits() {
return totalHits;
}
public void setTotalHits(int totalHits) {
this.totalHits = totalHits;
}
public List<HitsBean> getHits() {
return hits;
}
public void setHits(List<HitsBean> hits) {
this.hits = hits;
}
public static class HitsBean {
private int id;
private String pageURL;
private String type;
private String tags;
private String previewURL;
private int previewWidth;
private int previewHeight;
private String webformatURL;
private int webformatWidth;
private int webformatHeight;
private String largeImageURL;
private int imageWidth;
private int imageHeight;
private int imageSize;
private int views;
private int downloads;
private int favorites;
private int likes;
private int comments;
private int user_id;
private String user;
private String userImageURL;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPageURL() {
return pageURL;
}
public void setPageURL(String pageURL) {
this.pageURL = pageURL;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getTags() {
return tags;
}
public void setTags(String tags) {
this.tags = tags;
}
public String getPreviewURL() {
return previewURL;
}
public void setPreviewURL(String previewURL)