繁体   English   中英

Android ListView不会滚动

[英]Android ListView wont scroll

我已经尝试了很多事情来使我的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:layout_height="wrap_content"更改为android:layout_height="match_parent" 我猜它不会滚动,因为当您将高度设置为"wrap_content" ,视图将超出活动中的可见区域,并且由于所有项目均被视为已显示(尽管不在可见区域中),因此不会不能滚动。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM