【问题标题】:Android ListView wont scrollAndroid ListView 不会滚动
【发布时间】:2014-02-23 12:48:58
【问题描述】:

我已经尝试了很多方法来让我的 android ListView 滚动。但是,我的尝试没有成功。下面是我的xml代码。

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >


    <ListView
        android:id="@+id/listview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fastScrollEnabled="true"
        android:listSelector="@color/theme_colour"
        android:scrollbarStyle="outsideInset">
        </ListView>


</RelativeLayout>


我还在下面添加了我的 java 代码。我不知道如何解决这个问题,非常感谢您的帮助。

package com.outdeh;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;

import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseQueryAdapter;

/**
 * Created by horacedaley on 2/15/14.
 */
public class EventsActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listview_main);
        populateListView();


    }

    public void populateListView(){
        ParseQueryAdapter<ParseObject> adapter =
                new ParseQueryAdapter<ParseObject>(this, new ParseQueryAdapter.QueryFactory<ParseObject>() {
                    public ParseQuery<ParseObject> create() {
                        // Here we can configure a ParseQuery to our heart's desire.
                        ParseQuery query = new ParseQuery("Events");
                        query.orderByAscending("eDate");
                        return query;
                    }
                });


        adapter.setTextKey("eTitle");
        ListView listView = (ListView) findViewById(R.id.listview);
        listView.setFastScrollEnabled(true);
        listView.setAdapter(adapter);

    }


}

【问题讨论】:

标签: android listview android-listview scroll


【解决方案1】:

尝试将android:layout_height="wrap_content"s 更改为android:layout_height="match_parent"。我猜它不会滚动,因为当您将高度设置为"wrap_content" 时,视图将超出活动中的可见区域,并且由于所有项目都被视为已显示(尽管不在可见区域中),因此不会不能滚动。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多