有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

我将毫秒从报警存储到数据库,数据库已经正确地存储了它们,因为我测试了它,在单个文本视图中显示它们,并且它显示了它们。但我的ListView只显示有8个数字的毫秒值,当有9个或更多数字时,它不会显示它们。这是我的列表视图:

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

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

    </ListView>

</LinearLayout>

我用于行的xml:

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

    <TextView
        xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
        安卓:id="@+id/text1"
        安卓:layout_width="match_parent"        
        安卓:gravity="center"
        安卓: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);
    }

共 (1) 个答案

  1. # 1 楼答案

    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.

    &lt?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" >
    &lt/ListView>

    &lt/LinearLayout>