Cast ViewGroup to ListView?


#1

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

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

@Override
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!


#2
(parent as ListView).performClick(...)

Not working for you?


#3

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