Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:ListView页眉和页脚行为未正确显示_Android_Android Layout_Listview - Fatal编程技术网

Android:ListView页眉和页脚行为未正确显示

Android:ListView页眉和页脚行为未正确显示,android,android-layout,listview,Android,Android Layout,Listview,这是我滚动视图时的视图。。它添加了额外的布局,可以在我的listview项中扩展一些空间 我应该分配哪些listview属性来修复它 这是我的列表视图 这段代码使我的listview显示了不需要的视图 初始化添加页眉和页脚两次,从而导致listview行为。。因为我还为我的setupListViewAdapter函数调用了listView.addFooterView 首先,列表视图中可以有多个页眉和页脚。每次调用addHeader()时,它都会将视图添加到列表页眉中。在一种情况下,当列表项为空

这是我滚动视图时的视图。。它添加了额外的布局,可以在我的listview项中扩展一些空间

我应该分配哪些listview属性来修复它

这是我的列表视图

这段代码使我的listview显示了不需要的视图

初始化添加页眉和页脚两次,从而导致listview行为。。因为我还为我的setupListViewAdapter函数调用了listView.addFooterView


首先,列表视图中可以有多个页眉和页脚。每次调用addHeader()时,它都会将视图添加到列表页眉中。在一种情况下,当列表项为空时。然后您需要设置适配器(null)。然后,只有您才能看到在页眉和页脚中添加的视图。

我想您必须发布完整的xml文件。它几乎有700行。。它还说这超出了允许的字符数。上面说允许的身体是30000卡,而我的是31000+卡..仔细检查一下,你是否使用android:layout\u weight?这是我的版面链接是的,我在那里使用它。。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ListView
        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:scrollbarStyle="outsideOverlay"
        android:overScrollMode="never"
        android:saveEnabled="false" />
</LinearLayout>




<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <RelativeLayout
        android:id="@+id/relativeHeader"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:cacheColorHint="@android:color/transparent" >

        <LinearLayout
            android:id="@+id/linearNumber"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginBottom="10dp"
            android:paddingBottom="5dp"
            android:paddingTop="5dp" >

            <TextView
                android:id="@+id/textViewNumber"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center_vertical|left"
                android:text="Number: "
                android:textStyle="bold"
                android:textColor="#000000" />

            <TextView
                android:id="@+id/textViewNumberValue"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center_vertical|left"
                android:text="222-222-222-222"
                android:textColor="#000000" />
        </LinearLayout>
    </RelativeLayout>
</LinearLayout>
    private void setupListViewAdapter(ListView listView, View headerView, View footerView){
    listView.setDividerHeight(5);
    listView.setFadingEdgeLength(200);
    listView.addHeaderView(headerView, null, false);
    listView.addFooterView(footerView, null, false);
    listView.setFastScrollEnabled(false);
    listView.setAdapter(mDataAdapter);
}
  private void initListView(LayoutInflater inflater, ViewGroup container) {
    View headerViewROR = inflater.inflate(R.layout.vp_ror_header, null,false);
    View footerViewROR = inflater.inflate(R.layout.vp_remarks_footer, null,false);

    listView.addHeaderView(headerViewROR, null, false); //--> multiple occurrence need to be removed
    listView.addFooterView(footerViewROR, null, false); //--> multiple occurrence need to be removed
    setupListViewAdapter(listView, headerViewROR,footerViewROR);
}
    private void setupListViewAdapter(ListView listView, View headerView, View footerView){
    listView.setDividerHeight(5);
    listView.setFadingEdgeLength(200);
    listView.addHeaderView(headerView, null, false);//--> here is another assignment
    listView.addFooterView(footerView, null, false);//--> here is another assignment
    listView.setScrollingCacheEnabled(false);
    listView.requestFocus(0);
    listView.setAdapter(mDataAdapter);
}