Hi, I can't seems to display multiple roll in listview. What is wrong
with my code?
It just display line 1 - fruit1 and fruit2-4 doesn't appear.

---
ArrayList<HashMap<String,String>> list =
new ArrayList<HashMap<String,String>>();

HashMap<String,String> map = new HashMap<String,String>();
map.put("fruit1","Apple");
map.put("fruit2", "Orange");
map.put("fruit3", "Pear");
map.put("fruit4", "Banana");
list.add(map);

SimpleAdapter adapter = new SimpleAdapter(this, list,
R.layout.fruit_list,
new String[] {"fruit1","fruit2","fruit3","fruit4"},
new int[] {R.id.fruit1,R.id.fruit2, R.id.fruit3, R.id.fruit4}
);
ListView lv=(ListView)findViewById(R.id.fruitView);
lv.setAdapter(adapter);

---
<?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">

<Spinner android:id="@+id/sort_by" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:entries="@array/
default_sorts">
</Spinner>

<ListView
android:id="@+id/fruitView"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>

---

<?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="wrap_content"
android:background="@drawable/selector"
android:padding="10sp">
<TextView
android:id="@+id/fruit1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMediumInverse"/>
<TextView
android:id="@+id/fruit2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMediumInverse"/>
<TextView
android:id="@+id/fruit3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMediumInverse"/>
<TextView
android:id="@+id/fruit4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMediumInverse"/>
</LinearLayout>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to