我将报警中的毫秒存储到数据库,数据库将它们全部正确存储起来,因为我测试它在单个TextView中显示它们并显示它们全部。但我的ListView只显示有8个数字的毫秒值,当有9个或更多的数字时它不会显示它们。这是我的ListView:
<?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 :(得分: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"?>
<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="match_parent" >
</ListView>
</LinearLayout>