我正在创建一个应用,并希望使用Groupie RecyclerView以状态加载图像。我正在尝试加载图像,但是它在运行时停止。但是,当我仅通过文本时,效果很好。我的代码有问题吗?
private fun perfromUploadStatus() {
val text = textView_status.text.toString()
val image = R.drawable.post_pic2
val status = Status(text, image)
if (status != null) {
adapter.add(addStatus(status))
}
}
class Status (val staus: String , val statusImageUrl : Int ){
constructor(): this ("",0)
}
class addStatus(val status: Status): Item<ViewHolder>(){
override fun getLayout(): Int {
return R.layout.postview
}
override fun bind(viewHolder: ViewHolder, position: Int) {
viewHolder.itemView.textView_post.text = status.staus
val url = status.statusImageUrl
val targetImage= viewHolder.itemView.post_img
Picasso.get().load(url).into(targetImage)
}
}