0

これは私のJavaリストです。

private void filldata() {
    ListView lv = (ListView) findViewById(android.R.id.list);

    String[] from = new String[] { comment, commentdate, commentposter };
    int[] to = new int[] { R.id.text_comment, R.id.text_commentdate,
            R.id.text_commentposter };
    List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
    for (int i = 0; i < 5; i++) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put(comment, "testing 1");
        map.put(commentdate, "testing 2");
        map.put(commentposter, "testing 3");
        fillMaps.add(map);
    }
    SimpleAdapter adapter = new SimpleAdapter(this, fillMaps,
            R.layout.newscommentlist, from, to);
    lv.setAdapter(adapter);
}

私に与えられた出力は

テスト3

テスト3

テスト3

でも私が欲しいのは

テスト1

テスト2

テスト3

私が期待することを達成する方法は?

更新しました:

これはnewscommentlist.xmlです

?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#ffffff" >

<TextView
    android:id="@+id/text_commentdate"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginRight="10px"
    android:layout_marginTop="10px"
    android:gravity="right"
    android:textColor="#ff0000"
    android:textSize="20px" />

<TextView
    android:id="@+id/text_comment"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10px"
    android:layout_marginRight="10px"
    android:layout_marginTop="10px"
    android:gravity="fill_horizontal"
    android:textColor="#000000"
    android:textSize="30px" />

<TextView
    android:id="@+id/text_commentposter"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10px"
    android:layout_marginRight="10px"
    android:layout_marginTop="10px"
    android:gravity="right"
    android:textColor="#000000"
    android:textSize="35px" />

これはnewscomments.xmlです

<ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10px" >
    </ListView>
4

1 に答える 1

0
private void filldata() {
    ListView lv = (ListView) findViewById(android.R.id.list);

    String[] from = new String[] { "comment", "commentdate", "commentposter" };
    int[] to = new int[] { R.id.text_comment, R.id.text_commentdate,
            R.id.text_commentposter };
    List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
    for (int i = 0; i < 5; i++) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("comment", "testing 1");
        map.put("commentdate", "testing 2");
        map.put("commentposter", "testing 3");
        fillMaps.add(map);
    }
    SimpleAdapter adapter = new SimpleAdapter(this, fillMaps,
            R.layout.newscommentlist, from, to);
    lv.setAdapter(adapter);
}
于 2012-04-26T11:17:55.867 に答える