-1

リストビューをスクロールしたい.しかし、リストビューのアイテムが画面の長さを超えた場合にのみリストビューがスクロールします.しかし、リストビューにアイテムが1つまたは10個あるかどうかにかかわらず、リストビューをスクロールしたい.私はこのコードを使用しましたが、機能していません.これに関するチュートリアルはありません。その方法を教えてください。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:paddingTop="10dp" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="100" >

        <EditText
            android:id="@+id/etSearch"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="98"
            android:background="@drawable/search_shape"
            android:cursorVisible="false"
            android:gravity="center"
            android:imeOptions="actionSearch"
            android:singleLine="true" >
        </EditText>

        <Button
            android:id="@+id/SearchBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:background="@drawable/search_selector" />
    </LinearLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <ListView
            android:id="@+id/listView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_above="@+id/moreBtn"
            android:layout_below="@+id/etSearch"
            android:scrollbarStyle="outsideInset"
            android:layout_marginTop="10dp" >
        </ListView>

        <Button
            android:id="@+id/moreBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="@drawable/more_selector"
            android:visibility="gone" />

        <ProgressBar
            android:id="@+id/progressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:visibility="invisible" />
    </RelativeLayout>

</LinearLayout>
4

2 に答える 2

0

私は1つの解決策を見つけました.Pull-To-Refreshと呼ばれています

Android Pull-to-Refresh の実装方法

https://github.com/erikwt/PullToRefresh-ListViewからダウンロードでき ます(Erik Wallentinsen に感謝)。しかし、正しく動作していません。

そこで、必要な変更を加えて、適切に動作するデモを 1 つ用意しました。

于 2012-06-27T17:50:33.660 に答える
-1

このXMLコードを試すことができます。

<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
   <ListView
   android:id="@+id/listView"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:layout_above="@+id/moreBtn"
   android:layout_below="@+id/etSearch"
   android:scrollbarStyle="outsideInset"
   android:layout_marginTop="10dp" >
   </ListView>
</ScrollView>
于 2012-06-27T11:54:03.937 に答える