我正在开发一个聊天应用程序,但我得到以下错误:找不到字段的getter。
这就是为什么我想在房间里用类型转换器把整数转换成字符串,但我在下面找不到任何示例用户.java模型类
@Entity public class User implements IChatUser {
@PrimaryKey(autoGenerate = true)
private Integer id;
@ColumnInfo(name = "name")
private String name;
@Ignore
Bitmap icon;
public User() {
}
@Ignore
public User(String name, Bitmap icon) {
this.name = name;
this.icon = icon;
}
@Override
public Integer getId() {
return this.id;
}
@Override
public String getName() {
return this.name;
}
public void setId(Integer id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
@Override
public Bitmap getIcon() {
return this.icon;
}
@Override
public void setIcon(Bitmap icon) {
this.icon = icon;
} }
下面伊查图瑟.kt
interface IChatUser {
fun getId(): String
fun getName(): String?
fun getIcon(): Bitmap?
fun setIcon(bmp: Bitmap)
}
在开发Android聊天应用时遇到错误:找不到字段的getter。为了解决这个问题,考虑将Integer类型的id字段通过类型转换器转换为String。在User.java模型类中,已经定义了Integer到String的getter方法,但在IChatUser接口中要求返回的是String类型的getId。这个冲突需要通过调整接口或者实现额外的转换逻辑来解决。
1198

被折叠的 条评论
为什么被折叠?



