See
Part Two here.
Android has several built-in ListView
layouts that you can easily use without defining your own layout XML.
The source code needs cleanup and better documentation but it should give you an idea how to use the built-in layout.
android.R.layout.activity_list_item
|
Source Code:
Git |
SVN
|
|
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="1dip"
android:paddingBottom="1dip"
android:paddingStart="8dip"
android:paddingEnd="8dip">
<ImageView android:id="@+id/icon"
android:layout_width="24dip"
android:layout_height="24dip"
/>
<TextView android:id="@android:id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingStart=
"?android:attr/listPreferredItemPaddingStart"
/>
</LinearLayout>
|
android.R.layout.simple_expandable_list_item_1
|
Source Code:
Git |
SVN
|
|
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height=
"?android:attr/listPreferredItemHeight"
android:paddingStart=
"?android:attr/expandableListPreferredItemPaddingLeft"
android:textAppearance=
"?android:attr/textAppearanceListItem"
android:gravity="center_vertical"
/>
|
android.R.layout.simple_expandable_list_item_2
|
Source Code:
Git |
SVN
|
|
<?xml version="1.0" encoding="utf-8"?>
<TwoLineListItem
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height=
"?android:attr/listPreferredItemHeight"
android:paddingTop="2dip"
android:paddingBottom="2dip"
android:paddingStart=
"?android:attr/expandableListPreferredItemPaddingLeft"
android:mode="twoLine"
>
<TextView android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dip"
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_alignStart="@android:id/text1"
android:textAppearance=
"?android:attr/textAppearanceSmall"
/>
</TwoLineListItem>
|
android.R.layout.simple_list_item_1
|
Source Code:
Git |
SVN |
Download Zip |
Tutorial
|
|
<?xml version="1.0" encoding="utf-8"?>
<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:paddingStart=
"?android:attr/listPreferredItemPaddingStart"
android:paddingEnd=
"?android:attr/listPreferredItemPaddingEnd"
android:minHeight=
"?android:attr/listPreferredItemHeightSmall"
/>
|
android.R.layout.simple_list_item_2
|
Source Code:
Git |
SVN |
Download Zip |
Tutorial
|
|
<?xml version="1.0" encoding="utf-8"?>
<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_marginStart=
"?android:attr/listPreferredItemPaddingStart"
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_alignStart="@android:id/text1"
android:textAppearance=
"?android:attr/textAppearanceSmall"
/>
</TwoLineListItem>
|
No comments:
Post a Comment