0

i have some dynamic list which grow on some inputs i also have tab and some layout above it .and i want to scroll them as well as list grow. in simple words just not load full list but scroll other things as i scroll list. i m doing something like this .

  <ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0"
                android:dividerPadding="5dp"
                android:orientation="horizontal" />

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_weight="0" />

            <FrameLayout
                android:id="@+android:id/realtabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" />
        </LinearLayout>
    </TabHost>
</ScrollView>

note i also want to scroll tabs . i m currently using this code

public static class Utility {
    public static void setListViewHeightBasedOnChildren(ListView listView) {
        ListAdapter listAdapter = listView.getAdapter(); 
        if (listAdapter == null) {
            // pre-condition
            return;
        }

        int totalHeight = 0;
        for (int i = 0; i < listAdapter.getCount(); i++) {
            View listItem = listAdapter.getView(i, null, listView);
            listItem.measure(0, 0);
            totalHeight += listItem.getMeasuredHeight();
        }

        ViewGroup.LayoutParams params = listView.getLayoutParams();
        params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
        listView.setLayoutParams(params);
    }
}

for make a listview but it when i load the screen it focuse the screen from the list not from the tabs. any one knew how to start focus it from the top please help

4

1 回答 1

0

您的 ListView 将始终独立于其他列表滚动。如果您想让所有内容一起滚动,那么您需要考虑使用 LinearLayout 模仿 ListView 并将每一行添加到布局中。这将强制布局遵循外部滚动视图容器。

于 2012-08-09T11:02:53.407 回答