Android开发:simple_list_item1和simple_list_item2有什么区别?

时间:2012-06-07 10:33:22

标签: android listview android-arrayadapter

我知道在Android中使用simple_list_item1来创建ListView。 simple_list_item2是什么?另外,如何更改ListView的整体外观?

示例代码: ListView lv; lv.setAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1,results));

1 个答案:

答案 0 :(得分:1)

simple_list_item2是一个LineListItem意味着只有一个TextView

<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceListItemSmall" android:gravity="center_vertical" android:paddingLeft="?android:attr/listPreferredItemPaddingLeft" android:paddingRight="?android:attr/listPreferredItemPaddingRight" android:minHeight="?android:attr/listPreferredItemHeightSmall" />

simple_list_item2是TwoLineListItem意味着有2个TextViews ......

 <TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:mode="twoLine">

      <TextView android:id="@android:id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="?android:attr/listPreferredItemPaddingLeft" android:layout_marginTop="8dip" android:textAppearance="?android:attr/textAppearanceListItem" />

      <TextView android:id="@android:id/text2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@android:id/text1" android:layout_alignLeft="@android:id/text1" android:textAppearance="?android:attr/textAppearanceSmall" />


</TwoLineListItem>

http://mylifewithandroid.blogspot.in/2008/03/my-first-meeting-with-simpleadapter.html

中使用