ArrayAdapter

 class WordsAdapter(context: Context,private val lyt:Int,items:ArrayList<Word>) : ArrayAdapter<Word>(context,lyt,items){

    override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
var i = convertView
if (i==null){
i = LayoutInflater.from(context).inflate(lyt,parent,false)
}
i?.let {
val txt1: TextView = it.findViewById(R.id.tv_default)
val txt2:TextView = it.findViewById(R.id.tv_miwork)
val ivLogo:ImageView = it.findViewById(R.id.iv_logo)
val word = getItem(position)
if (word != null) {
txt1.text = word.defaultTranslation
txt2.text = word.miWorkTranslation
}
}

return i!!
}
}

Comments