开发者

Listview below listview android

I want to have a listview containing some content. And below it, when you scroll to the buttom of the listview, a new header would be displayed followed with a new list vie开发者_StackOverflow中文版w. Is is possible?

//Edit The two listview need to have differet layout xml.

Have tried to put the second listview in a the footview of the first. But then the second listview is to small.

Here is my layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">

        <LinearLayout android:id="@+id/header"
            android:background="@drawable/app_topbar" android:layout_width="fill_parent"
            android:orientation="horizontal" android:layout_height="wrap_content"
            android:layout_alignParentTop="true">

            <TextView android:text="@string/headline_notused"
                android:gravity="center" android:textSize="24sp" android:textStyle="bold"
                android:textColor="@color/txtcolor" android:layout_width="fill_parent"
                android:layout_height="fill_parent"></TextView>

        </LinearLayout>

        <ProgressBar android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:layout_below="@+id/header"
            android:visibility="gone" style="?android:attr/progressBarStyleHorizontal"
            android:id="@+id/progressbarHorizontal" />

        <ListView android:id="@+id/notUsedList" android:divider="@android:color/transparent"
            android:dividerHeight="5dip" android:layout_height="wrap_content"
            android:layout_marginBottom="5dip" android:layout_width="fill_parent"
            android:layout_weight="1" 
            android:layout_below="@+id/progressbarHorizontal"></ListView>

        <LinearLayout android:orientation="vertical"
            android:layout_below="@+id/notUsedList" android:background="@drawable/app_background"
            android:layout_marginBottom="55dip" android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <LinearLayout android:id="@+id/myUsedHeader"
                android:background="@drawable/app_topbar" android:layout_marginTop="10dip"
                android:layout_width="fill_parent" android:orientation="horizontal"
                android:layout_height="wrap_content" android:layout_alignParentTop="true">

                <TextView android:text="@string/headline_used" android:gravity="center"
                    android:textSize="24sp" android:textStyle="bold" android:textColor="@color/txtcolor"
                    android:layout_width="fill_parent" android:layout_height="fill_parent"></TextView>

            </LinearLayout>

            <ListView android:id="@+id/usedList"
                android:divider="@android:color/transparent" android:dividerHeight="5dip"
                android:layout_height="fill_parent" android:layout_width="fill_parent"></ListView>

        </LinearLayout>
</RelativeLayout>


You mean listview with different sections and each sections having a header. Try this link Jeff sharkey adapter


You should detect when you arrive at the listview last item.

Then, you can change your adapter, change activity or wathever you find appropriate to display the new ListView:

Implement an OnScrollListener, set your ListView's onScrollListener and then you should be able to handle things correctly.

For example:

// Initialization stuff.
yourListView.setOnScrollListener(this);

// ... ... ...

@Override
public void onScroll(AbsListView lw, final int firstVisibleItem,
                 final int visibleItemCount, final int totalItemCount) {

    switch(lw.getId()) {
        case android.R.id.list:     

            final int lastItem = firstVisibleItem + visibleItemCount;
            if(lastItem == totalItemCount) {
                // Last item is fully visible. You will then need to start a New activity, maybe... Or change the layout.. I don't know!
            }
    }
}


yes it is possible. you can define one listview in linearlayout and onether in other linearlayout and put both in parent LinearLayout.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜