自动扩展的ListView根据列表视图数据适配器 [英] Expanding ListView automatically depending to list view data adapter

查看:128
本文介绍了自动扩展的ListView根据列表视图数据适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的布局。我的列表视图listView_ModeOfPayment从我的适配器显示的数据,但在观看它有一个滚动视图查看列表,我希望它是自动扩展到父。
我的列表视图高度配置WRAP_CONTENT。但我没有得到正确的输出。这有什么错我的布局?

 < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:方向=垂直
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:背景=#000000>
<! -
  < RelativeLayout的
      机器人:layout_width =FILL_PARENT
      机器人:layout_height =FILL_PARENT
      机器人:背景=#000000> - >        <! - 头开始 - >
        <的LinearLayout机器人:ID =@ + ID /头
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:paddingTop =5DP
                机器人:方向=垂直
                机器人:paddingBottom会=5DP>
                <! - 标识开始 - >
                < ImageView的机器人:layout_width =WRAP_CONTENT
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_marginLeft =10dp/>
                <! - 标志完 - >          <的LinearLayout
          机器人:ID =@ + ID / linearTypeOfPayment
          机器人:layout_width =FILL_PARENT
          机器人:layout_height =WRAP_CONTENT
          机器人:layout_alignParentLeft =真
          机器人:layout_below =@ + ID / linearMannerOfPayment
          机器人:方向=垂直
          机器人:paddingTop =5DP>          <的TextView
              机器人:ID =@ + ID / textViewTypeOfPayment
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=类型的付款:
              机器人:文字颜色=#FFFFFF/>          <的TextView
              机器人:ID =@ + ID / textViewTypeOfPaymentValue
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT              机器人:layout_marginLeft =15dp
              机器人:layout_marginBottom =10dp
              机器人:文字=支付价值类型
              机器人:文字颜色=#FFFFFF
              机器人:文字样式=大胆/>
          <的TextView
              机器人:ID =@ + ID / textViewModeOfPayment
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=MODE付款方式:
              机器人:文字颜色=#FFFFFF/>
      < / LinearLayout中>
         <的LinearLayout
          机器人:ID =@ + ID / linearTypeOfPayment
          机器人:layout_width =FILL_PARENT
          机器人:layout_height =WRAP_CONTENT
          机器人:layout_alignParentLeft =真
          机器人:layout_below =@ + ID / linearMannerOfPayment
          机器人:方向=垂直
          机器人:paddingTop =5DP>          <的TextView
              机器人:ID =@ + ID / textViewTypeOfPayment
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=类型的付款:
              机器人:文字颜色=#FFFFFF/>          <的TextView
              机器人:ID =@ + ID / textViewTypeOfPaymentValue
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT              机器人:layout_marginLeft =15dp
              机器人:layout_marginBottom =10dp
              机器人:文字=支付价值类型
              机器人:文字颜色=#FFFFFF
              机器人:文字样式=大胆/>
          <的TextView
              机器人:ID =@ + ID / textViewModeOfPayment
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=MODE付款方式:
              机器人:文字颜色=#FFFFFF/>
      < / LinearLayout中>
      <的LinearLayout
          机器人:ID =@ + ID / linearTypeOfPayment
          机器人:layout_width =FILL_PARENT
          机器人:layout_height =WRAP_CONTENT
          机器人:layout_alignParentLeft =真
          机器人:layout_below =@ + ID / linearMannerOfPayment
          机器人:方向=垂直
          机器人:paddingTop =5DP>          <的TextView
              机器人:ID =@ + ID / textViewTypeOfPayment
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=类型的付款:
              机器人:文字颜色=#FFFFFF/>          <的TextView
              机器人:ID =@ + ID / textViewTypeOfPaymentValue
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT              机器人:layout_marginLeft =15dp
              机器人:layout_marginBottom =10dp
              机器人:文字=支付价值类型
              机器人:文字颜色=#FFFFFF
              机器人:文字样式=大胆/>
          <的TextView
              机器人:ID =@ + ID / textViewModeOfPayment
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=MODE付款方式:
              机器人:文字颜色=#FFFFFF/>
      < / LinearLayout中>
      <的LinearLayout
          机器人:ID =@ + ID / linearTypeOfPayment
          机器人:layout_width =FILL_PARENT
          机器人:layout_height =WRAP_CONTENT
          机器人:layout_alignParentLeft =真
          机器人:layout_below =@ + ID / linearMannerOfPayment
          机器人:方向=垂直
          机器人:paddingTop =5DP>          <的TextView
              机器人:ID =@ + ID / textViewTypeOfPayment
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=类型的付款:
              机器人:文字颜色=#FFFFFF/>          <的TextView
              机器人:ID =@ + ID / textViewTypeOfPaymentValue
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT              机器人:layout_marginLeft =15dp
              机器人:layout_marginBottom =10dp
              机器人:文字=支付价值类型
              机器人:文字颜色=#FFFFFF
              机器人:文字样式=大胆/>
          <的TextView
              机器人:ID =@ + ID / textViewModeOfPayment
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=多个文本查看从列表视图顶部的
              机器人:文字颜色=#FFFFFF/>
      < / LinearLayout中>
        < / LinearLayout中>
        <! - 标题结束 - >
        &所述;! - 页脚开始 - >
        <! - 页脚完 - >        <! - 登录表单 - >        <的LinearLayout
            机器人:ID =@ + ID / MAIN1
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
            机器人:layout_above =@ + ID /页脚
            机器人:layout_below =@ ID /头
            机器人:方向=垂直>          <的LinearLayout
              机器人:ID =@ + ID / headerz
              机器人:layout_width =match_parent
              机器人:layout_height =WRAP_CONTENT
              机器人:weightSum =3
              机器人:背景=#f7f9f6>              <的TextView
                  机器人:ID =@ + ID / ITEM2
                  机器人:layout_width =WRAP_CONTENT
                  机器人:layout_height =FILL_PARENT
                  机器人:layout_weight =1
                  机器人:layout_marginRight =15dp
                  机器人:身高=30dip                  机器人:文字=付款方式
                  机器人:宽=275dip/>              <的TextView
                  机器人:ID =@ + ID /项目3
                  机器人:layout_width =WRAP_CONTENT
                  机器人:layout_height =FILL_PARENT
                  机器人:layout_weight =1                  机器人:身高=30dip
                  机器人:文字=金额
                  机器人:宽=275dip/>              <的TextView
                  机器人:ID =@ + ID / ITEM4
                  机器人:layout_width =WRAP_CONTENT
                  机器人:layout_height =FILL_PARENT
                  机器人:身高=30dip
                  机器人:文字=#参考                  机器人:layout_weight =1
                  机器人:宽=275dip/>
          < / LinearLayout中>          <查看
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =1dip
              机器人:背景=机器人:ATTR / listDivider/>          <的LinearLayout
              机器人:ID =@ + ID / layoutBeforeBtnNext
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT
              机器人:方向=垂直>              < ListView控件
                  机器人:ID =@ + ID / listView_ModeOfPayment
                  机器人:layout_width =FILL_PARENT
                  机器人:layout_height =FILL_PARENT>
              < /&的ListView GT;
          < / LinearLayout中>
          <的LinearLayout
            机器人:ID =@ + ID /页脚
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_alignParentBottom =真
                机器人:layout_below =@ + ID / MAIN1
                            机器人:方向=垂直>
            <的LinearLayout
          机器人:ID =@ + ID / linearLayout1
          机器人:layout_width =match_parent
          机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ + ID /页脚
            机器人:layout_gravity =底
          机器人:方向=横向
          机器人:填充=10dp>
          <按钮
              机器人:ID =@ + ID / btnBackP3
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT
              机器人:layout_weight =0.19
              安卓了minHeight =45dp
              机器人:文字=返回/>          <按钮
              机器人:ID =@ + ID / btnNextP3
              机器人:layout_width =80dp
              机器人:layout_height =WRAP_CONTENT
              机器人:layout_weight =0.15
              安卓了minHeight =45dp
              机器人:文字=下一步/>
      < / LinearLayout中>
        < / LinearLayout中>
      < / LinearLayout中>        <! - 登录表单完 - >
 &所述;! - &下; / RelativeLayout的&GT - →;
< / LinearLayout中>


  

下面是从适配器块对象为每列表项显示


 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
     机器人:方向=横向>     &所述;! - - >    <的LinearLayout
    机器人:方向=垂直
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent>
        < RelativeLayout的
              机器人:ID =@ + ID / relativeModeOfPaymentCheck
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:背景=#000000>      <的LinearLayout
          机器人:ID =@ + ID / linearForCheck
          机器人:layout_width =FILL_PARENT
          机器人:layout_height =WRAP_CONTENT          机器人:layout_alignParentLeft =真
          机器人:方向=垂直
          机器人:paddingTop =5DP>          <的TextView
              机器人:ID =@ + ID / textViewModeOfPaymentCheckValue
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =WRAP_CONTENT
              机器人:文字=支付价值的检查模式              机器人:layout_marginLeft =15dp
              机器人:文字样式=大胆
              机器人:文字颜色=#FFFFFF/>
     < / LinearLayout中>
          &所述;! - asdasda - >
          <的LinearLayout
              机器人:ID =@ + ID / linearForAmountModeOfPayment
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:layout_alignParentLeft =真
              机器人:layout_below =@ + ID / linearCheckDate
              机器人:方向=横向
              机器人:weightSum =2>              < RelativeLayout的
                  机器人:ID =@ + ID / relativeBlock100
                  机器人:layout_width =FILL_PARENT
                  机器人:layout_height =WRAP_CONTENT
                  机器人:layout_marginLeft =15dp
                  机器人:layout_weight =1
                  机器人:背景=#000000>                  <的TextView
                      机器人:ID =@ + ID / textViewModAmountCheck
                      机器人:layout_width =WRAP_CONTENT
                      机器人:layout_height =WRAP_CONTENT
                      机器人:文字=金额
                      机器人:文字颜色=#FFFFFF/>
              < / RelativeLayout的>              < RelativeLayout的
                  机器人:ID =@ + ID / relativeBlock101
                  机器人:layout_width =FILL_PARENT
                  机器人:layout_height =WRAP_CONTENT
                  机器人:layout_weight =1
                  机器人:背景=#000000>                  <的TextView
                      机器人:ID =@ + ID / textViewModeOfPayCheckValue
                      机器人:layout_width =WRAP_CONTENT
                      机器人:layout_height =WRAP_CONTENT
                      机器人:layout_alignParentTop =真
                      机器人:layout_centerHorizo​​ntal =真
                      机器人:文字颜色=#FFFFFF/>
              < / RelativeLayout的>
          < / LinearLayout中>
          <! - 发出支票的名字 - >
          <的LinearLayout
              机器人:ID =@ + ID / linearForNameCheckIssued
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:layout_alignParentLeft =真
              机器人:layout_below =@ + ID / linearForCheck
              机器人:方向=横向
              机器人:weightSum =2>              < RelativeLayout的
                  机器人:ID =@ + ID / relativeBlock101
                  机器人:layout_width =FILL_PARENT
                  机器人:layout_height =WRAP_CONTENT
                  机器人:layout_marginLeft =15dp
                  机器人:layout_weight =1
                  机器人:背景=#000000>                  <的TextView
                      机器人:ID =@ + ID / textViewBankNameCheckIssued
                      机器人:layout_width =WRAP_CONTENT
                      机器人:layout_height =WRAP_CONTENT
                      机器人:文字=中华银行股份有限公司。
                      机器人:文字颜色=#FFFFFF/>
              < / RelativeLayout的>
          < / LinearLayout中>
          <! - CHECK NUMBER - >
          <的LinearLayout
              机器人:ID =@ + ID / linearCheckNumber
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:layout_alignParentLeft =真
              机器人:layout_below =@ + ID / linearForNameCheckIssued
              机器人:方向=横向>              <的TextView
                  机器人:ID =@ + ID / textViewCheckNumber
                  机器人:layout_width =WRAP_CONTENT
                  机器人:layout_height =WRAP_CONTENT
                  机器人:layout_marginLeft =15dp
                  机器人:文字=#CHECK
                  机器人:文字颜色=#FFFFFF/>              <的TextView
                  机器人:ID =@ + ID / textViewCheckNumValue
                  机器人:layout_width =WRAP_CONTENT
                  机器人:layout_height =WRAP_CONTENT
                  机器人:文字颜色=#FFFFFF/>
          < / LinearLayout中>
         <! - 支票日期 - >
          <的LinearLayout
              机器人:ID =@ + ID / linearCheckDate
              机器人:layout_width =FILL_PARENT
              机器人:layout_height =WRAP_CONTENT
              机器人:layout_alignParentLeft =真
              机器人:layout_below =@ + ID / linearCheckNumber
              机器人:方向=横向>              <的TextView
                  机器人:ID =@ + ID / textViewCheckDate
                  机器人:layout_width =WRAP_CONTENT
                  机器人:layout_height =WRAP_CONTENT
                  机器人:layout_marginLeft =15dp
                  机器人:文字=检查日期
                  机器人:文字颜色=#FFFFFF/>              <的TextView
                  机器人:ID =@ + ID / textViewCheckDateValue
                  机器人:layout_width =WRAP_CONTENT
                  机器人:layout_height =WRAP_CONTENT
                  机器人:文字颜色=#FFFFFF/>
          < / LinearLayout中>
        <的LinearLayout
              机器人:ID =@ + ID / linearLineForCheck
              机器人:layout_width =WRAP_CONTENT
              机器人:layout_height =2DP
              机器人:layout_alignParentLeft =真
              机器人:layout_below =@ + ID / linearForAmountModeOfPayment
              机器人:方向=横向>                  <查看
                      机器人:ID =@ + ID / View201
                      机器人:layout_width =WRAP_CONTENT
                      机器人:layout_height =WRAP_CONTENT
                      机器人:背景=#FFFFFF/>
          < / LinearLayout中>
          < / RelativeLayout的>
          < / LinearLayout中>
< / LinearLayout中>


解决方案

的ListView不能内部滚动视图用作在这种情况下机器人将不能够理解在这种情况下,滚动什么(列表项或完整布局)。

这是一个经典的问题,人们进入了Android的发展。

解决方案是使用ListView的页眉和页脚,在这种情况下。查找下面的步骤,你需要做的: -


  1. 删除滚动型


  2. 请以上所有的ListView作为一个单独的布局,并添加一样的你的列表视图标题


  3. 请在下面的ListView一切作为一个单独的布局,并添加一样的你的列表视图页脚


问题解决了!

希望这有助于..

This is my layout. my list view listView_ModeOfPayment is displaying data from my adapter but in viewing it having an scroll view to view the list, i want it to be automatically expand to the parent. My listview height is configured wrap_content. but i'm not getting the right output. what's wrong with my layout?

    <LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000" >
<!-- 
  <RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="#000000" >-->

        <!--  Header  Starts-->
        <LinearLayout android:id="@+id/header"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:paddingTop="5dp"
                android:orientation="vertical"
                android:paddingBottom="5dp">
                <!-- Logo Start-->
                <ImageView  android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="10dp"/>
                <!-- Logo Ends -->









          <LinearLayout
          android:id="@+id/linearTypeOfPayment"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/linearMannerOfPayment"
          android:orientation="vertical"
          android:paddingTop="5dp" >

          <TextView
              android:id="@+id/textViewTypeOfPayment"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="TYPE OF PAYMENT :"
              android:textColor="#ffffff" />

          <TextView
              android:id="@+id/textViewTypeOfPaymentValue"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"

              android:layout_marginLeft="15dp"
              android:layout_marginBottom="10dp"
              android:text="TYPE OF PAYMENT VALUE"
              android:textColor="#ffffff"
              android:textStyle="bold" />
          <TextView
              android:id="@+id/textViewModeOfPayment"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="MODE OF PAYMENT :"
              android:textColor="#ffffff" />    
      </LinearLayout>
         <LinearLayout
          android:id="@+id/linearTypeOfPayment"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/linearMannerOfPayment"
          android:orientation="vertical"
          android:paddingTop="5dp" >

          <TextView
              android:id="@+id/textViewTypeOfPayment"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="TYPE OF PAYMENT :"
              android:textColor="#ffffff" />

          <TextView
              android:id="@+id/textViewTypeOfPaymentValue"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"

              android:layout_marginLeft="15dp"
              android:layout_marginBottom="10dp"
              android:text="TYPE OF PAYMENT VALUE"
              android:textColor="#ffffff"
              android:textStyle="bold" />
          <TextView
              android:id="@+id/textViewModeOfPayment"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="MODE OF PAYMENT :"
              android:textColor="#ffffff" />    
      </LinearLayout>
      <LinearLayout
          android:id="@+id/linearTypeOfPayment"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/linearMannerOfPayment"
          android:orientation="vertical"
          android:paddingTop="5dp" >

          <TextView
              android:id="@+id/textViewTypeOfPayment"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="TYPE OF PAYMENT :"
              android:textColor="#ffffff" />

          <TextView
              android:id="@+id/textViewTypeOfPaymentValue"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"

              android:layout_marginLeft="15dp"
              android:layout_marginBottom="10dp"
              android:text="TYPE OF PAYMENT VALUE"
              android:textColor="#ffffff"
              android:textStyle="bold" />
          <TextView
              android:id="@+id/textViewModeOfPayment"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="MODE OF PAYMENT :"
              android:textColor="#ffffff" />    
      </LinearLayout>
      <LinearLayout
          android:id="@+id/linearTypeOfPayment"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/linearMannerOfPayment"
          android:orientation="vertical"
          android:paddingTop="5dp" >

          <TextView
              android:id="@+id/textViewTypeOfPayment"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="TYPE OF PAYMENT :"
              android:textColor="#ffffff" />

          <TextView
              android:id="@+id/textViewTypeOfPaymentValue"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"

              android:layout_marginLeft="15dp"
              android:layout_marginBottom="10dp"
              android:text="TYPE OF PAYMENT VALUE"
              android:textColor="#ffffff"
              android:textStyle="bold" />
          <TextView
              android:id="@+id/textViewModeOfPayment"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="MANY TEXT VIEW FROM THE TOP OF THE LISTVIEW"
              android:textColor="#ffffff" />    
      </LinearLayout>       








        </LinearLayout>
        <!--  Header Ends -->
        <!-- Footer Start -->


        <!-- Footer Ends -->

        <!-- Login Form -->

        <LinearLayout
            android:id="@+id/main1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_above="@+id/footer"
            android:layout_below="@id/header"
            android:orientation="vertical" >

          <LinearLayout
              android:id="@+id/headerz"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:weightSum="3" 
              android:background="#f7f9f6" >

              <TextView
                  android:id="@+id/item2"
                  android:layout_width="wrap_content"
                  android:layout_height="fill_parent"
                  android:layout_weight="1"
                  android:layout_marginRight="15dp"
                  android:height="30dip"

                  android:text="Payment Mode"
                  android:width="275dip" />

              <TextView
                  android:id="@+id/item3"
                  android:layout_width="wrap_content"
                  android:layout_height="fill_parent"
                  android:layout_weight="1"

                  android:height="30dip"
                  android:text="Amount"
                  android:width="275dip" />

              <TextView
                  android:id="@+id/item4"
                  android:layout_width="wrap_content"
                  android:layout_height="fill_parent"
                  android:height="30dip"
                  android:text="Reference #"

                  android:layout_weight="1"
                  android:width="275dip" />
          </LinearLayout>

          <View
              android:layout_width="fill_parent"
              android:layout_height="1dip"
              android:background="?android:attr/listDivider" />

          <LinearLayout
              android:id="@+id/layoutBeforeBtnNext"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:orientation="vertical" >

              <ListView
                  android:id="@+id/listView_ModeOfPayment"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent" >
              </ListView>
          </LinearLayout>
          <LinearLayout
            android:id="@+id/footer"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
                android:layout_below="@+id/main1"
                            android:orientation="vertical" >


            <LinearLayout
          android:id="@+id/linearLayout1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
        android:layout_below="@+id/footer"


            android:layout_gravity="bottom"
          android:orientation="horizontal"
          android:padding="10dp" >
          <Button
              android:id="@+id/btnBackP3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="0.19"
              android:minHeight="45dp"
              android:text="Back" />

          <Button
              android:id="@+id/btnNextP3"
              android:layout_width="80dp"
              android:layout_height="wrap_content"
              android:layout_weight="0.15"
              android:minHeight="45dp"
              android:text="Next" />
      </LinearLayout>


        </LinearLayout>
      </LinearLayout>



        <!-- Login Form Ends -->
 <!--  </RelativeLayout>-->
</LinearLayout>

Here is the block objects from the adapter to be display per list item

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     android:orientation="horizontal"  >

     <!--   -->  

    <LinearLayout 
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
        <RelativeLayout
              android:id="@+id/relativeModeOfPaymentCheck"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:background="#000000" >

      <LinearLayout
          android:id="@+id/linearForCheck"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"

          android:layout_alignParentLeft="true"
          android:orientation="vertical"
          android:paddingTop="5dp" >

          <TextView
              android:id="@+id/textViewModeOfPaymentCheckValue"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Mode of Payment Value check"

              android:layout_marginLeft="15dp"
              android:textStyle="bold"
              android:textColor="#ffffff" />        
     </LinearLayout>
          <!-- asdasda -->
          <LinearLayout
              android:id="@+id/linearForAmountModeOfPayment"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_below="@+id/linearCheckDate"
              android:orientation="horizontal"
              android:weightSum="2" >

              <RelativeLayout
                  android:id="@+id/relativeBlock100"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="15dp"
                  android:layout_weight="1"
                  android:background="#000000" >

                  <TextView
                      android:id="@+id/textViewModAmountCheck"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="AMOUNT"
                      android:textColor="#ffffff" />
              </RelativeLayout>

              <RelativeLayout
                  android:id="@+id/relativeBlock101"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_weight="1"
                  android:background="#000000" >

                  <TextView
                      android:id="@+id/textViewModeOfPayCheckValue"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_alignParentTop="true"
                      android:layout_centerHorizontal="true"
                      android:textColor="#ffffff" />
              </RelativeLayout>
          </LinearLayout>
          <!-- name of check issued -->
          <LinearLayout
              android:id="@+id/linearForNameCheckIssued"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_below="@+id/linearForCheck"
              android:orientation="horizontal"
              android:weightSum="2" >

              <RelativeLayout
                  android:id="@+id/relativeBlock101"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="15dp"
                  android:layout_weight="1"
                  android:background="#000000" >

                  <TextView
                      android:id="@+id/textViewBankNameCheckIssued"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="RIZAL COMMERCIAL BANKING CORP."
                      android:textColor="#ffffff" />
              </RelativeLayout>
          </LinearLayout>


          <!-- CHECK NUMBER -->
          <LinearLayout
              android:id="@+id/linearCheckNumber"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_below="@+id/linearForNameCheckIssued"
              android:orientation="horizontal" >

              <TextView
                  android:id="@+id/textViewCheckNumber"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="15dp"
                  android:text="CHECK # : "
                  android:textColor="#ffffff" />

              <TextView
                  android:id="@+id/textViewCheckNumValue"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:textColor="#ffffff" />
          </LinearLayout>
         <!-- CHECK DATE -->
          <LinearLayout
              android:id="@+id/linearCheckDate"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_below="@+id/linearCheckNumber"
              android:orientation="horizontal" >

              <TextView
                  android:id="@+id/textViewCheckDate"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="15dp"
                  android:text="CHECK DATE : "
                  android:textColor="#ffffff" />

              <TextView
                  android:id="@+id/textViewCheckDateValue"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:textColor="#ffffff" />
          </LinearLayout> 


        <LinearLayout
              android:id="@+id/linearLineForCheck"
              android:layout_width="wrap_content"
              android:layout_height="2dp"
              android:layout_alignParentLeft="true"
              android:layout_below="@+id/linearForAmountModeOfPayment"
              android:orientation="horizontal" >

                  <View
                      android:id="@+id/View201"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:background="#ffffff" />
          </LinearLayout>  


          </RelativeLayout>
          </LinearLayout>
</LinearLayout>

解决方案

ListView cannot be used inside scrollview as in that case android will not be able to understand what to scroll(list item or complete layout) in that case.

This is a classic problem that people get into in the android development.

Solution to this is using ListView header and footer in this case. Find below steps you need to do : -

  1. Remove ScrollView

  2. Make everything above ListView as a seperate layout and add the same as header of your List View

  3. Make everything below ListView as a seperate layout and add the same as footer of your List View

Problem Solved!!

Hope this helps..

这篇关于自动扩展的ListView根据列表视图数据适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆