开发者

Android: ListView inside TabHost

I'm assigning a ListActivity as a Tab contnet. Everything is working fine, but I'm not able to see all the list item results. I'm seeign 2 items only that to the half of the 2nd item only visible, i know my list contains more than 100 items. Any guesses?

+++++ EDIT ++++

Tab view Layout:
================

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:background="@drawable/bg" android:layout_height="fill_parent">

    <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/tabhost" android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout android:orientation="vertical"
            android:layout_width="fill_parent" android:layout_height="fill_parent">
            <View android:layout_width="fill_parent" android:layout_height="0.5dip"
                android:background="#000" />
            <TabWidget android:id="@android:id/tabs"
                android:layout_width="fill_parent" android:layout_height="wrap_content"
                android:layout_marginLeft="0dip" android:layout_marginRight="0dip" />
            <View android:layout_width="fill_parent" android:layout_height="2dip"
                android:background="#696969" />
            <View android:layout_width="fill_parent" android:layout_height="2dip"
                android:background="#000" />
            <ScrollView android:id="@+id/ScrollView01"
                android:layout_width="fill_parent" android:layout_height="fill_parent">
                <FrameLayout android:id="@android:id/tabcontent"
                    android:layout_width="fill_parent" android:layout_height="wrap_content">

                </FrameLayout>
            </ScrollView>
        </LinearLayout>
    </TabHost>
</LinearLayout>


Tab Activity:
=============
onCreate():

        mTabHost = (android.widget.TabHost) findViewById(android.R.id.tabhost);
        mTabHost.setup(getLocalActivityManager());
        mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);

        Intent list1Intent = new Intent(LIST1);     
        View tabview1 = createTabView(mTabHost.getContext(), "Tab1");
        mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator(tabview1)
                .setContent(new Intent(list1Intent)));

        View tabview2 = createTabView(mTabHost.getContext(), "Tab2");
        mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator(tabview2)
                .setContent(commentsIntent));                               
        mTabHost.setCurrentTab(0);      


LIST1 layout:
=============
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns开发者_StackOverflow中文版:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" android:layout_height="fill_parent"
    android:background="@drawable/bg" android:orientation="vertical"
    android:id="@+id/rootView">

    <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:id="@+id/cs_list_empty"
        android:text="No Data"></TextView>

    <ListView android:id="@+id/android:list" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:cacheColorHint="#00000000"
        android:divider="#E6E8E9" android:dividerHeight="2dip" 
        android:clickable="false" android:choiceMode="none" android:focusable="false" />

</LinearLayout>

Thanks, Venkat Papana


You should not use the scrollview with ListActivity as it already implements scrolling and the scrollview will interupt the optimisations made for the list activity.

Make the tabcontent framelayout as

<FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" 
    android:layout_height="0dip" android:layout_weight="1.0"/>

This will make the framelayout to fill the entire remaining space.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜