如何使android listview可滚动? [英] How to make android listview scrollable?

查看:21
本文介绍了如何使android listview可滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个列表视图,但它们不滚动.我该如何纠正?

I have two listviews, but they don't scroll. How do I correct this?

这是我的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>**

推荐答案

永远不要把 ListView 放在 ScrollView 中.ListView 本身是可滚动的.

Never put ListView in ScrollView. ListView itself is scrollable.

这篇关于如何使android listview可滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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