agoda-com / Kakao

This repo is no longer supported. Please visit a https://github.com/KakaoCup/Kakao
Apache License 2.0
1.11k stars 102 forks source link

How to get item by index from some views' list in VerticalGridView? #197

Closed automaticqa closed 4 years ago

automaticqa commented 4 years ago

I have VerticalGridView that contains the list of noId ConstraintLayouts. Every ConstraintLayout is clickable but its content is not. I need to click on some constrainLayout by list index. Is it possible with Kakao methods? image

Thanks a lot!

Unlimity commented 4 years ago

Hi there! Well, your GridView is derived form RecyclerView, right? That means, that you can use KRecyclerView to access items. When you define an item class for KRecyclerView you have to specify constructor with argument of type Matcher. That matcher is matching to root view of the item. In that case you can use this matcher to access the root view itself:

class MyRecyclerItem(parent: Matcher<View>) : KRecyclerItem<MyRecyclerItem>(parent) {
    val root = KView { withMatcher(parent) }
}

Cheers!

automaticqa commented 4 years ago

Thanks a lot!