0

First it said that my listView is null. Fixed this. Then i debuged the Adapter and i found out that the getView and getItem are never called.

Here is my Adapter:

class PropertiesAdapter(private val context: Context, private val properties: ArrayList<Property>) : BaseAdapter() {
    override fun getCount(): Int {
        Log.d("getCount", "${properties.size}")
        return properties.size
    }

    override fun getItem(position: Int): Any {
        Log.d("getItem", "${properties[position]}")
        return properties[position]
    }

    override fun getItemId(position: Int): Long {
        Log.d("getItemId", "${position.toLong()}")
        return position.toLong()
    }

    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        Log.d("getView", "$properties")
        val property = properties[position]
        val layoutInflater = context.getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater
        val myView = layoutInflater.inflate(R.layout.property, null)

        myView.title.text = property.title
        myView.descr.text = property.descr
        myView.location.text = property.location
        myView.price.text = property.price

        return myView
    }
}

Here is my Log:

D/getCount: 3
D/getCount: 3
D/getItemId: 0
D/getItemId: 0
Bat Vani
  • 1
  • 3

0 Answers0