我正在尝试使用 RecyclerView 和 volley 将服务器中的数据放入我的应用程序中,现在正因为如此,我正在使用一个适配器,这是我的适配器类
class TypeAdapter(var con: Context, var list: ArrayList<TypeItems>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun onBindViewHolder(p0: RecyclerView.ViewHolder, p1: Int) {
(p0 as ItemView).bind(list[p1].cartype, list[p1].typetype, list[p1].modeltype, list[p1].photype)
}
override fun onCreateViewHolder(p0: ViewGroup, p1: Int): RecyclerView.ViewHolder {
val v= LayoutInflater.from(con).inflate(R.layout.car_model_item, p0, false)
return ItemView(v)
}
override fun getItemCount(): Int {
return list.size
}
class ItemView(itemVeiw: View) : RecyclerView.ViewHolder(itemVeiw) {
fun bind(car_type: String, type: String, modele: String, ph: String) {
Picasso.with(itemView.context).load(ph).into(itemView.type)
itemView.name.text= "$car_type $type"
itemView.model.text= modele
}
}
}
这是我的 TypeItems 类
class TypeItems(car_typetype: String, typetype: String, modeletype: String, phtype: String) {
var cartype:String = car_typetype
var typetype:String = typetype
var modeltype:String = modeletype
var photype:String = phtype
}
现在我想从我的列表中删除重复的项目,我想按 car_type 和类型和型号排序,如果该项目重复,我想删除它
一只名叫tom的猫
有只小跳蛙
摇曳的蔷薇
相关分类