データベースから取得したアイテムを表示するリストビュー ウィジェットを持つプログラムを作成しようとしています。リストビューに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>