Solution 1 :
If you have the image string, you need to use an image processing library for displaying your images in an image view. Some of the popular libraries are Coil, Glide and Picasso.
A simple way to display your image, if you are using let’s say Glide, would be
Glide.with(context).load(imgCar).into(itemView.imgCar)
Problem :
class AdapterPostagem ( val car: MutableList): RecyclerView.Adapter<AdapterPostagem.CarViewHolder>(){
inner class CarViewHolder ( itemView: View ): RecyclerView.ViewHolder( itemView ) {
fun bind(car: Car) {
with(car) {
itemView.txtNameCar.text = nameCar
itemView.txtBrandCar.text = brandCar
//This line, in AndroidStudio not accept this formated
itemView.imgCar.imageView = imgCar
itemView.txtDescri.text = descCar
itemView.txtPrice.text = priceCar
itemView.txtYearsCar.text = yearCar
}
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CarViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.adapter_postagem, parent, false)
return CarViewHolder( view )
}
override fun getItemCount(): Int = car.size
override fun onBindViewHolder(holder: CarViewHolder, position: Int) {
holder.bind( car[position])
}
}
Comments
Comment posted by Jorengarenar
Describe better you problem