1

データベースから取得したアイテムを表示するリストビュー ウィジェットを持つプログラムを作成しようとしています。リストビューにarrayadapterを設定すると、要素が表示されますが、上下にスクロールしません。これが私のコードで、ところで私はAndroid 2.3.3 avdを使用しています。

ListView lv;
lv = (ListView)findViewById(R.id.listView1);
String[] liste = new String[suggestion.size()];
//liste is populated afterwards, there are about 100 items
ArrayAdapter<String> adapterForList = new ArrayAdapter<String>(getApplicationContext(),R.layout.listview,R.id.word,liste );
lv.setAdapter(adapterForList);

ここに私のlistview.xmlがあります

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="5dp">
<TextView
        android:id="@+id/word"
        style="@android:style/TextAppearance.Large"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

アクティビティが使用するメインの xml ファイルを次に示します。上記のものは、リストビュー ウィジェット専用です。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <Spinner android:id="@+id/spinner1" android:layout_width="wrap_content"
        android:layout_height="wrap_content"></Spinner>
    <EditText android:id="@+id/etSQL" android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    </EditText>
</LinearLayout>


<ListView android:layout_width="fill_parent" android:id="@+id/listView1"
    android:layout_height="0dp" android:layout_weight="1"></ListView>
</LinearLayout>
4

3 に答える 3

1

あなたの XML には何も含まれていませんListView...

于 2011-10-10T14:20:14.880 に答える
0

問題は、プログラムのスピナーが原因でした。理由はわかりませんが、スピナーを取り外した後に機能しました。

于 2011-10-13T20:05:49.740 に答える
0

興味深い状況があります。私が理解していれば、コードは実行されています。唯一の問題はスクロールです.. :)) (間違ったxmlファイル)

于 2011-10-10T14:38:05.987 に答える