gpt4 book ai didi

android - ListView 每页仅显示一个数据

转载 作者:行者123 更新时间:2023-11-29 08:14:02 24 4
gpt4 key购买 nike

我正在从 MySQL 数据库加载 ListView 中的数据,一切正常,除了我的 ListView 每页显示一个数据,如果我向下滚动,则显示第二个数据,如果再次向下滚动,则显示第三个数据。它不是一个接一个地显示。那么问题是什么,我需要设置任何属性或其他任何内容吗?请帮助我,下面是我的代码。

enter image description here

我的 XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/classes_slider"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back_bg"
android:orientation="vertical" >


<ImageView
android:id="@+id/headerbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/headerbar_small" />

<ImageView
android:id="@+id/skirrlogo"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="50dp"
android:layout_marginTop="10dp"
android:src="@drawable/skirrwhite" />

<ImageView
android:id="@+id/skirrmenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:src="@drawable/slideropener" />

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/skirrlogo"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/skirrlogo"
android:text="@string/classses"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />

<ImageView
android:id="@+id/newclass"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/headerbar"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:src="@drawable/class_button_new" />

<ImageView
android:id="@+id/deletemenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/skirrlogo"
android:src="@drawable/menubutton_large" />

<ListView
android:id="@+id/displaydata"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/newclass" >

</ListView>

</RelativeLayout>

自定义类.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/back_bg" >

<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/classname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textStyle="bold" />

</LinearLayout>

这就是我在 ListView 中加载数据的方式:

/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
Classes_Ext_DB.this, productsList,
R.layout.custom_class, new String[] {
TAG_CLASSNAME, TAG_ID },
new int[] { R.id.classname });
mListView.setAdapter(adapter);

最佳答案

因此,只需从 Customclass.xml 中删除 android:background="@drawable/back_bg" 即可,一切正常。

关于android - ListView 每页仅显示一个数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20966332/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com