0

Just like a ListView but instead it doesn't scroll. Its content is added programatically via an ArrayAdapter. Is there any view that can be used for this purpose?

PS: Not LinearLayout, since it doesn't get its content from an adapter (I want the observer pattern)

Edit: Let me explain a little bit more. Suppose you need a list of items, but the list itself is not scrollable, what is scrollable is the screen.

That being said, the list of items should show ALL items, not a limited amount based on a fixed height. The way to go is LinearLayout as it is both non-scrollable and shows all items within itself.

But there is a third requierement. You don't want to add(View) directly, but instead, you want something similar to an ArrayAdapter so that you have a control of the items and their position, so you can handle on item click events based on their position. As far as I know, this can't be done using a LinearLayout. So my question is, does any view exist for this purpose?

Christopher Francisco
  • 15,672
  • 28
  • 94
  • 206

2 Answers2

0

You could try using a ListView, but disable scrolling, as described here

Community
  • 1
  • 1
moomin
  • 59
  • 3
0

Put your layout inside a ScrollView and yes you have to use a Linearlayout. You need to set tag for each of your view that you add dynamically and whenever your view is clicked you can get it's position by view.getTag() and perform the required operation.

Note : Adding views at run time may affect performance.

CodeWarrior
  • 5,026
  • 6
  • 30
  • 46