I create frames like this. The number can change throughout runtime.
for (i in (1..numStations(serverText)))// number of frames
{
frame = ScrollView(this@HomeActivity)
layoutInflater.inflate(R.layout.frame_layout, frame)
frame.tag = i.toString()
gridRoot.addView(frame)
}
frame_layout is FrameLayout with some images and texts. I have set focusable and clickable to true on FrameLayout. So I want to detect when a frame is clicked and which one (I added tags starting with 1).