如何让Android的ListView滚动? [英] How to make android listview scrollable?
本文介绍了如何让Android的ListView滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个列表视图,但他们不滚动。如何纠正呢?
下面是我的 layout.xml
< XML版本=1.0编码=UTF-8&GT?;
<滚动型的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:fillViewport =真正的>
< RelativeLayout的
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@可绘制/ backgrund>
<! - 标题开始 - >
<的LinearLayout
机器人:ID =@ + ID /头
机器人:layout_width =FILL_PARENT
机器人:layout_height =40dip
机器人:layout_alignParentTop =真
机器人:背景=@布局/头>
< / LinearLayout中>
<! - 标头结束 - >
&所述;! - 页脚开始 - >
<的TextView
机器人:ID =@ + ID / textAD
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignBottom =@ + ID /头
机器人:layout_alignParentRight =真
机器人:layout_marginBottom =14dp
机器人:layout_marginRight =26dp
机器人:文本=小文
机器人:textAppearance =机器人:ATTR / textAppearanceSmall
机器人:文字颜色=#FFFFFF/>
< ImageView的
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID /头
机器人:layout_gravity =center_horizontal
机器人:可聚焦=假
机器人:paddingBottom会=5像素
机器人:paddingTop =10px的
机器人:SRC =@机器人:可绘制/ divider_horizontal_bright/>
<查看
机器人:layout_width =FILL_PARENT
机器人:layout_height =1dip
机器人:后台=#000000
机器人:可聚焦=FALSE/>
<的LinearLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID / linearLayout1
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:layout_below =@ + ID /头
机器人:方向=垂直>
<的TextView
机器人:ID =@ + ID / TEXTM
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:文本=Malzemeler
机器人:TEXTSIZE =20dp
机器人:文字颜色=#000000/>
<的EditText
机器人:ID =@ + ID / editaramalzeme
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:EMS =10/>
<按钮
机器人:ID =@ + ID / btnmalzlist
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:可聚焦=假
机器人:文本=阿拉/>
<的ListView
机器人:ID =@ + ID / mylist中
机器人:layout_width =match_parent
机器人:layout_height =420dp
机器人:layout_weight =1
机器人:后台=#FFFFFF>
< / ListView控件>
<的ListView
机器人:ID =@ + ID / listsecili
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =210dp
机器人:layout_weight =1
机器人:后台=#FFFFFF>
< / ListView控件>
<的EditText
机器人:ID =@ + ID / txtNot
机器人:layout_width =match_parent
机器人:layout_height =88dp
机器人:EMS =10
机器人:重力=顶
机器人:inputType =textMultiLine
机器人:行=6
机器人:单线=假>
<不是requestFocus />
< /的EditText>
< / LinearLayout中>
<按钮
机器人:ID =@ + ID / btnkaydet
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_below =@ + ID / linearLayout1
机器人:文本=malzeme ekle/>
<按钮
机器人:ID =@ + ID / btntoplugonder
风格=机器人:ATTR / buttonStyleSmall
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignRight =@ + ID / textAD
机器人:layout_below =@ + ID / btnkaydet
机器人:文本=toplu gonder/>
< / RelativeLayout的>
< /滚动型> **
解决方案
在滚动view.Listview本身永远不要把列表视图是滚动的。
I have two listviews, but they don't scroll. How do I correct this?
Here is my layout.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/backgrund" >
<!-- Header Starts -->
<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_alignParentTop="true"
android:background="@layout/header" >
</LinearLayout>
<!-- Header Ends -->
<!-- Footer Start -->
<TextView
android:id="@+id/textAD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/header"
android:layout_alignParentRight="true"
android:layout_marginBottom="14dp"
android:layout_marginRight="26dp"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header"
android:layout_gravity="center_horizontal"
android:focusable="false"
android:paddingBottom="5px"
android:paddingTop="10px"
android:src="@android:drawable/divider_horizontal_bright" />
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#000000"
android:focusable="false" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/header"
android:orientation="vertical" >
<TextView
android:id="@+id/textm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Malzemeler"
android:textSize="20dp"
android:textColor="#000000"/>
<EditText
android:id="@+id/editaramalzeme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<Button
android:id="@+id/btnmalzlist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:text="Ara" />
<ListView
android:id="@+id/mylist"
android:layout_width="match_parent"
android:layout_height="420dp"
android:layout_weight="1"
android:background="#FFFFFF" >
</ListView>
<ListView
android:id="@+id/listsecili"
android:layout_width="wrap_content"
android:layout_height="210dp"
android:layout_weight="1"
android:background="#FFFFFF" >
</ListView>
<EditText
android:id="@+id/txtNot"
android:layout_width="match_parent"
android:layout_height="88dp"
android:ems="10"
android:gravity="top"
android:inputType="textMultiLine"
android:lines="6"
android:singleLine="false" >
<requestFocus />
</EditText>
</LinearLayout>
<Button
android:id="@+id/btnkaydet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/linearLayout1"
android:text="malzeme ekle" />
<Button
android:id="@+id/btntoplugonder"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textAD"
android:layout_below="@+id/btnkaydet"
android:text="toplu gonder" />
</RelativeLayout>
</ScrollView>**
解决方案
Never put listview in scroll view.Listview itself is scrollable.
这篇关于如何让Android的ListView滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文