Reputation: 19
I am using LinearLayout
with vertical orientation and inside that layout I am having four ListView
. This layout I have placed inside ScrollView
.
My problem is ScrollView
is not scrolling. So I am not able to see my all list views.
What i am doing is:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView1"
android:layout_width="wrap_content"
android:layout_height="600dp"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/frag_capt2"
android:layout_width="800dp"
android:layout_height="match_parent"
android:layout_marginLeft="100dp"
android:layout_marginTop="20dp"
android:orientation="vertical" >
<TextView
android:id="@+id/linearlayoutteamtv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
<ListView
android:id="@+id/ListView01team"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/pm_cool_listproject_background" >
</ListView>
<TextView
android:id="@+id/linearlayoutteamtv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
<ListView
android:id="@+id/ListView02team"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/pm_cool_listproject_background" >
</ListView>
<TextView
android:id="@+id/linearlayoutteamtv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
<ListView
android:id="@+id/ListView03team"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/pm_cool_listproject_background" >
</ListView>
<TextView
android:id="@+id/linearlayoutteamtv4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
<ListView
android:id="@+id/ListView04team"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/pm_cool_listproject_background" >
</ListView>
</LinearLayout>
</ScrollView>
I do not understand what my code is missing.
Upvotes: 1
Views: 2470
Reputation: 11026
You just can't do that that way! However, there is solution to you problem, multiple types of list items within single list. Differences between single type list items:
(header, list1_type, list2_type,... main_header?, main_footer?)
, override getViewTypeCount()
getItemViewType(...)
,
is index_of_header -> 0
is index_of_type1 -> 1
is index_of_type2 -> 2
getView(...)
convertView
argument is view for current item type, you should reuse it, if not null!You may create your own abstract class for merging adapter, as mentioned in another answer. It's just basically what I explained above. Sometimes you just can't use merge adapter, ie. recursive structures, but there is good idea to consider using ExpandableListView
.
Upvotes: 0
Reputation: 1584
A listview
should NOT be inside any scrolling element or vice versa. please have a look at what google developers have to say about it.Please check this Video
Upvotes: 1
Reputation: 4255
you can set all four listview height..like...
<ListView
android:id="@+id/lst_tree_hazard"
android:layout_width="fill_parent"
android:layout_height="80dp" ///set the height based on your listview content
android:scrollbars="none" >
</ListView>
Upvotes: 1
Reputation: 13785
Generally, you cannot put scrollable things inside other scrollable things, where they scroll in the same direction, and have the results be reliable. Occasionally this works (e.g., WebViews
in a ViewPager
), but that is the exception, not the norm.
Either:
Move the ListView
out of the ScrollView
, or
Move all the rest of the contents of the ScrollView into the ListView, whether using things like addHeaderView()
or my MergeAdapter
Upvotes: 0
Reputation: 4252
You dont need to have a ScrollView
for a ListView
. I think you can easily use RelativeLayout
and specify the order of the ListViews
Upvotes: 0