开发者

Static headers on a listview

I have a ListActivity with obviously a ListView on it. This ListView consists of different sections, each of them have a header.

When I display the list of items to the user, first header is on top. If user scrolls, header is hidden and rest of items are displayed. I know how to make that simple header static, always on top,开发者_C百科 but what i want now, is to have last displayed header always on top.

Last version of GMail is a good example of what i want. While on a message, if you scroll, you will always see that message header on top. If you keep scrolling and go to next message, when that new message header is about to disappear because of the scrolling action, it will replace the current static header, so that user will have always current message's header on top, as a floating panel.

Is there any example out there, or some guidance about how to implement this?

Thanks!


I havn't tried this out but I think this could be done using a LinearLayout, in this example a TextView should remain static at the top:

<?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:layout_height="fill_parent">
    <TextView
    android:text="row one"
    android:textSize="15pt"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"/>

    <ListView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"/>

</LinearLayout>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜