相対レイアウトにあるリストビューにいくつかのアイテムを表示しようとしています。全体のレイアウトは 1 つの xml ファイル (main.xml) にあります。
レイアウトには、2 つのボタンと 2 つのテキストフィールド (EditText) もあります。
次のように、私はそれを機能させることができません:
リストビューに項目が表示されない
リストビューが展開されると、レイアウトに存在するボタンとテキストフィールドが複製されます
誰かが私を助けてくれますか?
レイアウトの一部を次に示します。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/kpnback">
<EditText
android:layout_height="wrap_content"
android:layout_width="110dp"
android:id="@+id/editText1"
android:text="edit1"
android:inputType="textMultiLine"
android:layout_below="@+id/lbl_top">
</EditText>
<EditText
android:layout_height="wrap_content"
android:layout_width="110dp"
android:id="@+id/editText2"
android:text="edit2"
android:inputType="textMultiLine"
android:layout_marginLeft="160dp"
android:layout_below="@+id/lbl_top">
</EditText>
<ListView
android:layout_width="fill_parent"
android:layout_height="20dp"
android:id="@+id/kpn"
android:layout_y="350dp"
android:layout_below="@+id/editText1">
</ListView>
</RelativeLayout>
simpleadapter のコード:
@Override
protected void onPostExecute(String result) {
// create the grid item mapping
ListView kp = (ListView)findViewById(R.id.kpn);
String[] from = new String[] {"col_1", "col_2"};
int[] to = new int[] { R.id.editText1, R.id.editText1 };
List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
Document doc = Jsoup.parse(kpn);
Elements tdsFromSecondColumn = doc.select("table.personaltable td:eq(0)");
Elements tdsFromSecondColumn1 = doc.select("table.personaltable td:eq(1)");
for (Element tdFromSecondColumn : tdsFromSecondColumn) {
map.put("col_1", tdFromSecondColumn.text());
fillMaps.add(map);
System.out.println(tdFromSecondColumn.text());
}
for (Element tdFromSecondColumn1 : tdsFromSecondColumn1) {
map.put("col_2", tdFromSecondColumn1.text());
fillMaps.add(map);
System.out.println(tdFromSecondColumn1.text());
}
SimpleAdapter adapter = new SimpleAdapter(AndroidLogin.this, fillMaps, R.layout.main, from, to);
kp.setAdapter(adapter);