我的 foodview.imageView.setImageResource(food.image!!) 有问题,错误未解决参考:imageView
override fun getView(index: Int, convertView: View?, parent: ViewGroup?): View {
var food :Food = this.foodlist[index]
var inflater :LayoutInflater = context!!.getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater
var foodview = inflater.inflate(R.layout.mylayout,null)
foodview.imageView.setImageResource(food.image!!)
foodview.textView.text = food.name!!
return foodview
}
答案 0 :(得分:0)
当您尝试使用 setImageResource() 设置图像时,您传递的参数必须是 int 例如。 setImageResource(R.drawable.image)。检查变量 food.image 的值