Ben Edwards
09/05/2022, 6:33 PMoverride fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
Log.d(TAG, "getView called pos $position")
// if convertView is null inflate it otherwise use it
val view =
if (convertView == null) {
Log.d(TAG,"getView called with null convertView")
inflater.inflate(resource, parent, false)
} else {
Log.d(TAG,"getView privided a convertView")
convertView
}
val tvName: TextView = view.findViewById(R.id.tvName)
val tvArtist: TextView = view.findViewById(R.id.tvArtist)
val tvSummary: TextView = view.findViewById(R.id.tvSummary)
val currentApp = applications[position] // position from constructor
tvName.text = currentApp.name
tvArtist.text = currentApp.artist
tvSummary.text = currentApp.summary
return view
}
Its the 'val view =' bit I have a question about. I get what it is doing, i.e. only running the inflator if needed. What I don't get is why when the method is run again convertView is set. i.e. when is convertView set to view?efemoney
09/05/2022, 7:15 PMBen Edwards
09/06/2022, 10:17 PM