我现在用listview显示数据 我再java代码里给listview用addHeaderView(view v)方法设置了页眉 但是在显示的时候确实显示在第一行 但是当数据过多我往下滚动时添加的的页眉也跟着滚动了!请问怎样能设置成不滚动的啊?有什么方法让第一行不滚动吗!!

解决方案 »

  1.   

    你可以在listview控件的上面再放控件用于显示你的页眉!
      

  2.   

    你用addHeaderView(view v)方法设置了页眉,当然滚动的时候就会跟着滚动。这是一定的
    你要想不滚动的话,按下面的界面改<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
            android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
            >
    <!-- 不动的页眉 -->
    <TextView android:id="@+id/lab"
    android:layout_width="wrap_content" 
                            android:layout_height="wrap_content"
    android:text="不动的页眉" />
    <ListView android:id="@+id/lv" 
                      android:layout_width="fill_parent"
      android:layout_height="fill_parent" 
                      android:layout_below="@id/lab"
    ></ListView>
    </RelativeLayout>