开发者

Android: Populating multiple items in a listview row

开发者 https://www.devze.com 2022-12-23 00:49 出处:网络
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:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消