【发布时间】:2013-01-31 20:00:35
【问题描述】:
我正在将警报中的毫秒数存储到数据库中,并且数据库已正确存储它们,因为我测试它在单个 TextView 中显示它们并显示它们全部。但是我的 ListView 只显示有 8 个数字的毫秒值,当有 9 个或更多数字时,它不会显示它们。这是我的列表视图:
<?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);
}
【问题讨论】:
-
不显示还是只显示9位以上的8位?
-
@Simon 显示 8 位或更少,9 或更多根本不显示,如果它的 9 位或更多位,则不会显示整数(行)。好像根本不存在(但在数据库里)
-
@Simon 因此,如果它的数字为 8 位或更少,它将显示在 ListView 的行中,但如果它的数字为 9 位,则不会填充到 ListView 中。
-
这很奇怪。我会尝试编写自己的适配器并进行测试。 blog.cluepusher.dk/2009/11/16/…
标签: java android database listview