Why Listview Cannot Be Used In A Scrollview?
Solution 1:
The problem is not the ListView but the ScrollView
Those two views need to takes controll of vertical scrolling, if you have a scrollview and a listview in the same layout and the user scroll down, which one have to take the focus and so the scroll?
This is a common problem that has a common and easy solution (this solution comes from Romain Guy from Google Android team!): don't use a listview in a scrollview!
If you want an interesting video/talk you can watch it from Google I/O talks: The world of ListView I really suggest you to take a look :)
Solution 2:
It's because both views are scrollable. Have you already tried to search/google for it? There are thousand matches..
http://www.google.de/search?sourceid=chrome&ie=UTF-8&q=android+listview+in+scrollview
Solution 3:
The ListView has built in capabilities to scroll. You don't need to define it again within a ScrollView
Solution 4:
ListViews are not supposed to get in ScrollView. Even if you hack, and i mean big hack, both views by extending them and got them to scroll , also be itemclickable etc etc , something will break eventually. Also do not add a ListView to a Scroll View.
Solution 5:
I have tested with below xml and it works. But still trying to handle the onTouchEvent function between the ScrollView and ListView. You can Click here to see the original solution.
<?xml version="1.0" encoding="utf-8"?><ScrollViewxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"xmlns:quilt="http://schemas.android.com/apk/res-auto"android:id="@+id/scrollview"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent" ><ListViewandroid:id="@+id/inner_listview"android:layout_width="match_parent"android:layout_height="match_parent" /></LinearLayout></ScrollView>
Post a Comment for "Why Listview Cannot Be Used In A Scrollview?"