2013-01-31 25 views
2

我從報警到數據庫和數據庫的存儲時間都是毫秒,因爲我測試了它們在單個TextView中顯示它們並將它們全部顯示出來,所以它們都正確存儲。但是我的ListView只顯示有8個數字的毫秒值,當有9個或更多數字時它不顯示它們。這是我的ListView:Android的ListView不能顯示超過8位數字

<?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="match_parent" 
    android:orientation="vertical" > 

    <ListView 
     android:id="@android:id/list" 
     android:layout_width="match_parent" 
     android:layout_height="250dp" > 

    </ListView> 

</LinearLayout> 

我的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="match_parent" 
    android:orientation="vertical" > 

    <TextView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/text1" 
     android:layout_width="match_parent"   
     android:gravity="center" 
     android:layout_height="45dp" /> 

</LinearLayout> 

方法,我使用的填充的ListView:

private void fillData() { 
     // Get all of the notes from the database and create the item list 
     Cursor c = DatabaseManager.getAllData(); 
     startManagingCursor(c); 

     String[] from = new String[] { DatabaseManager.TABLE_COLUMN_TWO }; 
     int[] to = new int[] { R.id.text1 }; 

     // Now create an array adapter and set it to display using our row 
     SimpleCursorAdapter notes = 
      new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to); 
     setListAdapter(notes); 
    } 
+0

它不顯示他們還是隻顯示9位或更多的8位數? – Simon

+0

@Simon它顯示8位數或更少,根本不顯示9位或更多,如果9位或更多位數字不顯示整個數字(行)。像它根本不存在(但它在數據庫中) – user2027663

+0

@Simon因此,如果它的數字爲8或更少,它將顯示在ListView的行中,但是如果它的數字是9位數字,它不會在ListView中填充。 – user2027663

回答

0

Please replace the Listview with following code. 
Its working good.
Don't fix the height of the Listview in android:layout_height
Please replace your layout xml code with the following xml.

<?xml version="1.0" encoding="utf-8"?>
&ltLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

&ltListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>

</LinearLayout>
+0

感謝您的建議,但它不起作用。嘗試在3.2英寸(320x480)屏幕上進行測試,您將看到它無法工作。它在較大的屏幕上工作,但較小的屏幕不工作。 – user2027663

+0

我在不同的設備上測試過它。它的工作正常。你使用的是什麼版本,你可以添加屏幕截圖。你在模擬器還是移動設備上測試? – Shaahul