2014-01-07 59 views
0

我正在從MySQL數據庫的列表視圖中加載數據,一切工作正常,除了我的列表視圖顯示每頁一個數據,如果我向下滾動然後第二個數據如果再次我向下滾動然後第三個數據。它並沒有一個接一個地顯示出來。那麼問題是什麼,我需要設置任何財產或其他任何東西。請幫我下面是我的代碼。列表視圖顯示每頁只有一個數據

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> 

Customclass.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> 

我這是如何加載在列表視圖數據:

/** 
       * 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); 
+0

你是什麼意思的一個數據?每頁有一個數據? ListView似乎在一個單一的頁面中使用,並有多個行 – Skynet

+3

檢查您的back_bg大小,我認爲,back_bg大小很大... –

+0

@AstralProjection,我現在添加圖像,如果我向下滾動然後只有我能夠看到其他數據,它不會在我的第一個數據下面加載其他數據。它正在爲一個數據進行整個活動頁面。 – InnocentKiller

回答

2

所以,只需從您的Customclass.xml中刪除您的android:background="@drawable/back_bg",一切正常。

0

custom_class.xml與Customclass.xml相同嗎?檢查並確保。

相關問題