Hello, I need to put several listviews inner a LinearLayout. The Listviews should be wrap content to adapt the listview to their items. I need have one only scroll with which I can scroll all the listviews. I know that i can't use a scrollview because the listviews have their own scroll (but i don't need the scrolls of the listviews because i have them in wrap-content). I thought maybe puting the listviews inside the LinearLayout I will hadn't problems with the scrollview, but it didn't work, the LinearLayout was fixed to the screen, the scrollview didn't appear and the listviews ended scrollable. Without the scrollview if i have the list in wrap-content, their shown properly but i haven't any scroll and i can't see the lisviews below the screen. Really i have had this bug for one month and i haven't found any solution, i am desperate :(
My code:
XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/detail_info_on_top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FF003150"
android:orientation="vertical">
<!--<ScrollView android:layout_width="fill_parent"-->
<!-- android:layout_height="fill_parent"-->
<!-- android:fillViewport="true">-->
<LinearLayout
android:id="@+id/layout"
android:scrollbars="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</LinearLayout>
<!--</ScrollView>-->
JAVA
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
...
LinearLayout layout = (LinearLayout)findViewById(R.id.layout);
ArrayList<SectionHolder> shs = SObjectDB.SOBJECTS.get(sobject).detail;
for(SectionHolder sh : shs) {
/** layout by each section */
ListView lsvDetails = new ListView(this);
lsvDetails.setPadding(0, 0, 0, 0);
lsvDetails.setBackgroundColor(0xFFFFFFFF);
lsvDetails.setCacheColorHint(Color.TRANSPARENT);
lsvDetails.setFocusable(false);
lsvDetails.setSelected(false);
lsvDetails.setScrollContainer(false);
lsvDetails.setVerticalScrollBarEnabled(false);
LinearLayout ll = new LinearLayout(this);
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llp);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setFocusable(false);
/** setting section header */
TextView sv = new TextView(this);
sv.setText(sh.name);
sv.setTextSize(15);
sv.setTextColor(0xFFFFFFFF);
sv.setBackgroundColor(0xFF656565);
sv.setWidth(480);
//sv.setTypeface(null, Typeface.BOLD);
ll.addView(sv);
...
LinkedHashMap<String,String> hm;
final ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
hm = new LinkedHashMap<String, String>();
for(FieldHolder fs : fhs) {
hm = new LinkedHashMap<String, String>();
...
hm.put("data", v1);
mylist.add(hm);
}
ListView.LayoutParams lsvp = new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT, ListView.LayoutParams.WRAP_CONTENT);
lsvDetails.setLayoutParams(lsvp);
lsvDetails.setScrollbarFadingEnabled(false);
lsvDetails.setScrollingCacheEnabled(false);
lsvDetails.setSelector(R.drawable.multi_white_color);
lsvDetails.setDrawSelectorOnTop(false);
lsvDetails.setAdapter(new DetailAdapter(this, mylist, R.layout.grid_detail, new String[]{"label", "data"}, new int[]{R.id.lblName, R.id.lblData}));
ll.addView(lsvDetails);
layout.setVerticalScrollBarEnabled(true);
layout.setScrollbarFadingEnabled(true);
layout.setScrollBarStyle(50331648);
layout.setScrollContainer(true);
layout.setFocusable(true);
layout.setFocusableInTouchMode(true);
layout.addView(ll);
}
}
How you can see i create the lisviews dinamically and i put indside the layout with a secttion header. if you have some doubt ask me I need find a solution soon. Thanks
Sample Image: http://www.freeimagehosting.net/image.php?6dea1468bd.png