gpt4 book ai didi

java - Android ListView 不显示超过 8 位数字

转载 作者:搜寻专家 更新时间:2023-10-30 20:57:53 26 4
gpt4 key购买 nike

我正在将从警报到数据库的毫秒数存储起来,并且数据库已将它们全部正确存储,因为我测试它在单个 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);
}

最佳答案

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>

关于java - Android ListView 不显示超过 8 位数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14634113/

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