Gibt es eine Möglichkeit, mehrere TextView mit ArrayAdapter zu aktualisieren?
Ich habe eine Listenansicht mit mehreren Textansichten wie folgt:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16dip"
android:textColor="#000000"
android:paddingLeft="10dip"
android:textStyle="bold"/>
<TextView
android:id="@+id/address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16dip"
android:textColor="#000000"
android:paddingTop="15dip"
android:paddingBottom="15dip"
android:paddingLeft="10dip"
android:textStyle="bold"/>
</RelativeLayout>
Ich habe eine Liste von POJO's, die eine hatname
undaddress
und ich möchte, dass jedes Element in der Listenansicht mit diesen Werten gefüllt wird.
Mein POJO sieht so aus:
public class Person {
private String name;
private String address;
//getter setter
public String toString() {return name;}
}
Frage
Wenn ich den Listenadapter mit meiner Liste einstelle, wie kann ich dann sowohl Namen als auch Adresse einstellen?
Momentan mache ich das, was nur den Namen festlegt:
setListAdapter(new ArrayAdapter<Person>(MyActivity.this, R.layout.list_text, R.id.name, personList));