I'm trying to populate a list, and my question is how do you bind the list row with multiple items. So far I have:
String[] homeLists = getResources().getStringArray(R.array.homeItems);
setListAdapter(new ArrayAdapter<String>(this, R.layout.home_item, R.id.homeItemName, homeLists));
home_item looks like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="@+id/homeItemName"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp"/>
If开发者_如何学Python I add another TextView say "homeItemDec", how will I bind both homeItemName and homeItemDesc in my setListAdapter call?
Once you get beyond a basic list item, you probably want to start making your own adapter and returning a custom view for each cell. Code sample here
精彩评论