Reputation: 1924
My listview below contains only one textview per row. I need another textview to add a second textview to my row. the problem is i dont know how to populate more than one textview. it there is a second textview txIndex for example. How can i modify my adapter to populate data from two textviews.
String[] bible_list_one = getResources().getStringArray(R.array.bible_list_one);
String[] bible_list_two = getResources().getStringArray(R.array.bible_list_two);
list.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, bible_list_one));
list.setOnItemClickListener(this);
secondlist.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, bible_list_two));
secondlist.setOnItemClickListener(this);
Upvotes: 0
Views: 805
Reputation: 1617
Check this out: Android Hive Link
<?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="100dp"
android:background="@drawable/listselect"
android:orientation="horizontal"
android:padding="5dip" >
<TextView
android:id="@+id/txtViewNameDAR"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name : "
android:textColor="#040404"
android:textSize="15sp"
android:textStyle="bold"
android:typeface="sans" />
<TextView
android:id="@+id/txtViewVisitedCityDAR"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Type : "
android:textColor="#343434"
android:textSize="13sp" />
<TextView
android:id="@+id/textViewTypeDAR"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Visited City : "
android:textColor="#343434"
android:textSize="13sp" />
</RelativeLayout>
Change the IDs and colors to your needs.
This is an independent XML file. Use it like below :
list.setAdapter(new ArrayAdapter<String>(this,
"R.Layout.ABOVE_XML_FILENAME, bible_list_one));
Then, In getView
TextView text = (TextView) row.findViewById(" Your Desired textViewID");
text.setText(" ");
Hope you get some idea
Upvotes: 0
Reputation: 1157
You will have to write your own CustomArrayAdapter. I hope the tutorial link is helpful.
Upvotes: 2