Cast ViewGroup to ListView?

I have a code on Java. This is the code inside getView method of BaseAdapter.

viewHolder.button1 = (Button) convertView.findViewById(;
viewHolder.button1.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
    ((ListView) parent).performItemClick(v, position, 0); // Let the event be handled in onItemClick()

So, the question is, how to cast parent (ViewGroup) to ListView in Kotlin?
Thank you for your answers!

(parent as ListView).performClick(...)

Not working for you?

Thank you very much! My first app on kotlin. :wink:

1 Like