I have two listviews, but they don\'t scroll. How do I correct this?
Here is my layout.xml
Putting ListView
inside a ScrollView
is never inspired.
But if you want your posted XML-like behavior, there're 3 options to me:
Remove ScrollView
: Removing your ScrollView
, you may give the ListView
s some specific size with respect to the total layout (either specific dp
or layout_weight
).
Replace ListView
s with LinearLayout
s: You may add the list-items by iterating through the item-list and add each item-view to the respective LinearLayout
by inflating the view & setting the respective data (string, image etc.)
If you really need to put your ListView
s inside the ScrollView
, you must make your ListView
s non-scrollable (Which is practically the same as the solution 2 above, but with ListView
codes), otherwise the layout won't function as you expect.
To make a ListView
non-scrollable, you may read this SO post, where the precise solution to me is like the one below:
listView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
return (event.getAction() == MotionEvent.ACTION_MOVE);
}
});