假设其中有一个RecyclerView包含CardView,在每张卡片中,即项目中有两个TextView用于设备名称,另一个用于 rssi 级别,因此当用户刷新数据时,只有 rssi 会刷新而不是整个列表刷新.
我已经获得了数据,RecyclerView但它是重复的而不是更新它。
模型类:-
import android.support.annotation.NonNull;
public class RepeaterModel implements Comparable,Cloneable{
public String macdev;
public int rssi ;
public int imageid;
public RepeaterModel(String macdev, int rssi, int imageid) {
this.macdev = macdev;
this.rssi = rssi;
this.imageid = imageid;
}
public String getMacdev() {
return macdev;
}
public void setMacdev(String macdev) {
this.macdev = macdev;
}
public int getRssi() {
return rssi;
}
public void setRssi(int rssi) {
this.rssi = rssi;
}
public int getImageid() {
return imageid;
}
public void setImageid(int imageid) {
this.imageid = imageid;
}
@Override
public int compareTo(@NonNull Object o) {
RepeaterModel compare =(RepeaterModel)o;
if(compare.getMacdev().equals(this.macdev) && compare.getImageid()==this.imageid && compare.getRssi()==this.rssi)
{
return 0;
}
return 1;
}
@Override
public RepeaterModel clone()
{
RepeaterModel clone;
try {
clone = (RepeaterModel) super.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e); //should not happen
}
return clone;
}
}
慕婉清6462132
慕村9548890
繁花如伊
森栏
相关分类