もののリストが表示された画面のこのレイアウトがあります。
<?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"
>
<include android:id="@+id/header"
layout="@layout/header"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
<TextView
android:id="@+id/loading_questions"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Text for please wait while questions load. If the questions do not load, check your Internet connection. Questions are stored in a secure remote database so that you do not lose your work."
android:textSize="12sp"
/>
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</LinearLayout>
私のコードでは、次のようにロードします。
ListView list = (ListView) findViewById(R.id.list);
次に、次のように入力します。
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
// My data
private List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
SimpleAdapter adapter = new SimpleAdapter(this, fillMaps, R.layout.questions_list,
new String[] {"train", "to"},
new int[] {R.id.TRAIN_CELL, R.id.TO_CELL});
// This was the middle item R.id.FROM_CELL,
list.setAdapter(adapter);
list.setTextFilterEnabled(true);
アイテムが読み込まれると、このアダプターを再設定するだけです。
question_list.xml ファイルは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="4dip"
android:paddingBottom="6dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:textSize="13sp">
<TextView android:id="@+id/TRAIN_CELL"
android:layout_width="275dip"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/TO_CELL"
android:layout_width="25dip"
android:textSize="20sp"
android:textStyle="bold"
android:gravity="center"
android:src="@drawable/arrow_button"
android:textColor="@color/light_best_blue"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
また、2 列のリストをレンダリングしますが、ヘッダー ナビゲーションが無効になり (ボタンが機能しなくなり)、ヘッダーの周りにも白い境界線が表示されるという問題があります。
これがなぜ起こるのか、そしてそれを修正する方法を誰かが知っていますか?
ありがとう!