我的列表视图中没有得到滚动 [英] My list view does not get scrolled
问题描述
PFB我的布局
我的ListView没有得到滚动
我有下面的一个相对布局3名单
它是喜欢当我点击相对布局结构列表变得可见。
它当我点击相对布局,数据填充后,工作正常。
但名单似乎并不滚动。
<滚动型
机器人:layout_width =match_parent
机器人:layout_height =580dp> <的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginLeft =20dp
机器人:layout_marginRight =20dp
机器人:layout_marginTop =20dp
机器人:背景=@绘制/ bg_box
机器人:方向=垂直
机器人:填充=20dp> < RelativeLayout的
机器人:ID =@ + ID / landrel
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:背景=@绘制/酒吧> <的TextView
机器人:ID =@ + ID / landHoldingtext
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_centerVertical =真
机器人:layout_marginLeft =63dp
机器人:文字=土地控股:0 LAND
机器人:文字颜色=#FFFFFF/> < ImageView的
机器人:ID =@ + ID / arrowLandHolding
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_alignRight =@ + ID / landHoldingtext
机器人:layout_marginRight =50dp
机器人:layout_marginTop =24dp
机器人:SRC =@绘制/ up_aarow/>
< / RelativeLayout的> < ListView控件
机器人:ID =@ + ID / landHoldingList
机器人:layout_width =match_parent
机器人:layout_height =100dp
机器人:知名度=水涨船高>
< /&的ListView GT; < RelativeLayout的
机器人:ID =@ + ID / familyrel
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =10dp
机器人:背景=@绘制/酒吧> <的TextView
机器人:ID =@ + ID / familyDetailstext
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_centerVertical =真
机器人:layout_marginLeft =63dp
机器人:文字=FAMILY DETAILS:0 MEMEBER
机器人:文字颜色=#FFFFFF/> < ImageView的
机器人:ID =@ + ID / arrowFamily
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_alignRight =@ + ID / familyDetailstext
机器人:layout_marginRight =50dp
机器人:layout_marginTop =24dp
机器人:SRC =@绘制/ up_aarow/>
< / RelativeLayout的> < ListView控件
机器人:ID =@ + ID / familyDetailsList
机器人:layout_width =match_parent
机器人:layout_height =100dp
机器人:知名度=水涨船高>
< /&的ListView GT; < RelativeLayout的
机器人:ID =@ + ID / bankrel
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =10dp
机器人:背景=@绘制/酒吧> <的TextView
机器人:ID =@ + ID / bankDetailstext
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_centerVertical =真
机器人:layout_marginLeft =63dp
机器人:文字=银行信息
机器人:文字颜色=#FFFFFF/> < ImageView的
机器人:ID =@ + ID / arrowBank
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_alignRight =@ + ID / bankDetailstext
机器人:layout_marginRight =50dp
机器人:layout_marginTop =24dp
机器人:SRC =@绘制/ up_aarow/>
< / RelativeLayout的> < ListView控件
机器人:ID =@ + ID / bankDetailsList
机器人:layout_width =match_parent
机器人:layout_height =100dp
机器人:知名度=水涨船高>
< /&的ListView GT; < RelativeLayout的
机器人:ID =@ + ID / otherrel
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =10dp
机器人:背景=@绘制/酒吧> <的TextView
机器人:ID =@ + ID / otherDetailsText
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_centerVertical =真
机器人:layout_marginLeft =63dp
机器人:文字=其他细节
机器人:文字颜色=#FFFFFF/> < ImageView的
机器人:ID =@ + ID / arrowOther
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_alignRight =@ + ID / otherDetailsText
机器人:layout_marginRight =50dp
机器人:layout_marginTop =24dp
机器人:SRC =@绘制/ up_aarow/>
< / RelativeLayout的> < ListView控件
机器人:ID =@ + ID / otherDetailsList
机器人:layout_width =match_parent
机器人:layout_height =100dp
机器人:知名度=水涨船高>
< /&的ListView GT; <的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =10dp
机器人:重力=CENTER_HORIZONTAL
机器人:方向=横向
机器人:weightSum =2> <的LinearLayout
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:重力=CENTER_HORIZONTAL
机器人:方向=垂直 > < ImageView的
机器人:ID =@ + ID / aadharCardImgView
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =10dp 机器人:SRC =@绘制/ aadhar_card_butt_copy/> <的TextView
机器人:ID =@ + ID / aadharCardTxtView
机器人:layout_marginTop =5DP
机器人:layout_marginBottom =10dp
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文字=Aadhar卡/> < / LinearLayout中>
<的LinearLayout
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:重力=CENTER_HORIZONTAL
机器人:方向=垂直 > < ImageView的
机器人:ID =@ + ID / passbookImgView
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =10dp 机器人:layout_weight =1
机器人:SRC =@绘制/ passbook_butt/>
<的TextView
机器人:ID =@ + ID / passbookTxtView
机器人:layout_marginTop =5DP
机器人:layout_marginBottom =10dp
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文字=存折/> < / LinearLayout中> < / LinearLayout中>
< / LinearLayout中>
< /滚动型>
我的适配器布局
<?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:背景=@绘制/ field_bar_bg
机器人:weightSum =6
机器人:方向=横向> <的TextView
机器人:paddingTop =25dp
机器人:ID =@ + ID / RSnumberTxt
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:比重=中心
机器人:layout_weight =1
机器人:文字=一分之一百二十六/> <的TextView
机器人:ID =@ + ID /类型
机器人:paddingTop =25dp
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:比重=中心
机器人:layout_weight =1
机器人:文字=棕榈油/> <的TextView
机器人:ID =@ + ID /年
机器人:paddingTop =25dp
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:比重=中心
机器人:layout_weight =1
机器人:文字=2007-08/> < ImageView的
机器人:ID =@ + ID / visitButton
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:SRC =@绘制/ visit_button/> < ImageView的
机器人:ID =@ + ID / yieldButton
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:SRC =@绘制/ yield_button/> < ImageView的
机器人:ID =@ + ID / landButton
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =1
机器人:SRC =@绘制/ land_button/>< / LinearLayout中>
背后的原因吧 - 你的列表视图里面滚动型
的做如下解决您的烦恼 - 的
的ListView LV =(ListView控件)findViewById(R.id.landHoldingList); //你的滚动视图里面的ListView
lv.setOnTouchListener(新ListView.OnTouchListener(){
@覆盖
公共布尔onTouch(视图V,MotionEvent事件){
INT行动= event.getAction();
开关(动作){
案例MotionEvent.ACTION_DOWN:
//不允许滚动型拦截触摸事件。
。v.getParent()requestDisallowInterceptTouchEvent(真);
打破; 案例MotionEvent.ACTION_UP:
//允许滚动型拦截触摸事件。
。v.getParent()requestDisallowInterceptTouchEvent(假);
打破;
} //处理ListView控件触摸事件。
v.onTouchEvent(事件);
返回true;
}
});
这样做是禁用的滚动型的TouchEvents,使ListView控件拦截下来。它是简单和工程所有的时间。
PFB my layout
My listView does not get scrolled I have 3 list below one relative layout Its the structure that like when I click on Relative Layout The list gets visible . Its working fine when I click on relative layout and after the data is populated . But the list does not seem to scroll.
<ScrollView
android:layout_width="match_parent"
android:layout_height="580dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:background="@drawable/bg_box"
android:orientation="vertical"
android:padding="20dp" >
<RelativeLayout
android:id="@+id/landrel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bar" >
<TextView
android:id="@+id/landHoldingtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="63dp"
android:text="LAND HOLDING : 0 LAND"
android:textColor="#FFFFFF" />
<ImageView
android:id="@+id/arrowLandHolding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignRight="@+id/landHoldingtext"
android:layout_marginRight="50dp"
android:layout_marginTop="24dp"
android:src="@drawable/up_aarow" />
</RelativeLayout>
<ListView
android:id="@+id/landHoldingList"
android:layout_width="match_parent"
android:layout_height="100dp"
android:visibility="gone" >
</ListView>
<RelativeLayout
android:id="@+id/familyrel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/bar" >
<TextView
android:id="@+id/familyDetailstext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="63dp"
android:text="FAMILY DETAILS : 0 MEMEBER"
android:textColor="#FFFFFF" />
<ImageView
android:id="@+id/arrowFamily"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignRight="@+id/familyDetailstext"
android:layout_marginRight="50dp"
android:layout_marginTop="24dp"
android:src="@drawable/up_aarow" />
</RelativeLayout>
<ListView
android:id="@+id/familyDetailsList"
android:layout_width="match_parent"
android:layout_height="100dp"
android:visibility="gone" >
</ListView>
<RelativeLayout
android:id="@+id/bankrel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/bar" >
<TextView
android:id="@+id/bankDetailstext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="63dp"
android:text="BANK DETAILS "
android:textColor="#FFFFFF" />
<ImageView
android:id="@+id/arrowBank"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignRight="@+id/bankDetailstext"
android:layout_marginRight="50dp"
android:layout_marginTop="24dp"
android:src="@drawable/up_aarow" />
</RelativeLayout>
<ListView
android:id="@+id/bankDetailsList"
android:layout_width="match_parent"
android:layout_height="100dp"
android:visibility="gone" >
</ListView>
<RelativeLayout
android:id="@+id/otherrel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/bar" >
<TextView
android:id="@+id/otherDetailsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="63dp"
android:text="OTHER DETAILS "
android:textColor="#FFFFFF" />
<ImageView
android:id="@+id/arrowOther"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignRight="@+id/otherDetailsText"
android:layout_marginRight="50dp"
android:layout_marginTop="24dp"
android:src="@drawable/up_aarow" />
</RelativeLayout>
<ListView
android:id="@+id/otherDetailsList"
android:layout_width="match_parent"
android:layout_height="100dp"
android:visibility="gone" >
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:weightSum="2" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical"
>
<ImageView
android:id="@+id/aadharCardImgView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:src="@drawable/aadhar_card_butt_copy" />
<TextView
android:id="@+id/aadharCardTxtView"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Aadhar Card" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical"
>
<ImageView
android:id="@+id/passbookImgView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:src="@drawable/passbook_butt" />
<TextView
android:id="@+id/passbookTxtView"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Passbook" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
My Adapter Layout
<?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:background="@drawable/field_bar_bg"
android:weightSum="6"
android:orientation="horizontal" >
<TextView
android:paddingTop="25dp"
android:id="@+id/RSnumberTxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="126/1" />
<TextView
android:id="@+id/type"
android:paddingTop="25dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="Oil Palm" />
<TextView
android:id="@+id/year"
android:paddingTop="25dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="2007-08" />
<ImageView
android:id="@+id/visitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/visit_button" />
<ImageView
android:id="@+id/yieldButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/yield_button" />
<ImageView
android:id="@+id/landButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/land_button" />
</LinearLayout>
The reason behind that it - Your listview is inside ScrollView
Do as following to fix your trouble -
ListView lv = (ListView)findViewById(R.id.landHoldingList); // your listview inside scrollview
lv.setOnTouchListener(new ListView.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow ScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
// Allow ScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
// Handle ListView touch events.
v.onTouchEvent(event);
return true;
}
});
What this does is disable the TouchEvents on the ScrollView and make the ListView intercept them. It is simple and works all the time.
这篇关于我的列表视图中没有得到滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!