I need to implement a 3 list of items within the same view. Each list of item cannot be scrolled individually, but the whole view could be scrolled. Before, I did it by include 3 ListView within a ScrollView, and then stretch 3 ListView to it's fullest. But that cause some troubles, so I need help. Any ideas how to implement this ?
Asked
Active
Viewed 46 times
0
-
possible duplicate of [Non-scrollable ListView inside ScrollView](http://stackoverflow.com/questions/18813296/non-scrollable-listview-inside-scrollview) – mmking Sep 20 '15 at 02:22
-
I will try that. I did try to make ListView inside ScrollView, but then, if the content displayed varied, the effect is not as expected. – Nguyen Quang Anh Sep 20 '15 at 17:51
-
It didn't behave like I want. If you have a list of contents to display, some need 1 line, some need 4 or 5 lines, then this method is out of question. Because, you will need the exact width inside `onMeasure`. I solved this by render all the views once, then get the exact width and render it again inside the callback. The view appeared is exactly as I wanted, but then there's another problem, because the new `View` create with a total new component (TextView, Button, etc), and I don't want that, that's why I need another method – Nguyen Quang Anh Sep 21 '15 at 10:27
1 Answers
0
Since, you want that Each list of item cannot be scrolled individually
, I'd suggest using a single ListView
but with sections. There are various tutorials as to how add sections to a ListView
, quickest one I could find is given here.
It'll work, you just need to manage your getItemViewType(int)
and getViewTypeCount()
methods properly. So you say you want from 3 different classes. So your getViewTypeCount()
should return 4
1 - Section Headers
3 - For the 3 different classes, each class will have different view.
And then you need to adjust your views in your getView()
methods, based upon the position in the list.
-
Each list of item, is from different classes, so it may not work. – Nguyen Quang Anh Sep 20 '15 at 17:52