I am new in android.
I have a list that must be viewed like this:
PIC NAME DESC
I have a list of buckets that contains all 3 info above.
The problem is, I can only make one field appear in the view. In this case, the bucket.getBucketName().
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
List<Bucket> buckets = BucketHandler.getBucketList();
List<String> bucketList = new ArrayList<String>();
for (Bucket bucket : buckets){
bucketList.add(bucket.getBucketName());
}
setListAdapter(new ArrayAdapter<String>(this, R.layout.row,
R.id.bucket_list, bucketList));
}
MY .xml is as follows:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:drawSelectorOnTop="false"/>
<TextView
android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/noData"/>
</LinearLayout>
Row Layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/lightgray">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/none"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/bucket_list"
android:layout_width="210dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"/>
<TextView
android:id="@+id/bucket_percentage"
android:layout_marginTop="15dp"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
/>
<TextView
android:id="@id/android:hidden_id"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
/>
</LinearLayout>
How can I render all three fields inside the item list?
Thank you.
Create your own custom adapter by extending ArrayAdapter and override getView () method