Android
android.widget
public class

android.widget.TwoLineListItem

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
android.view.ViewGroup ViewManager ViewParent
android.widget.RelativeLayout
android.widget.TwoLineListItem

A view group with two children, intended for use in ListViews. This item has two TextViews elements (or subclasses) with the ID values text1 and text2. There is an optional third View element with the ID selectedIcon, which can be any View subclass (though it is typically a graphic View, such as ImageView) that can be displayed when a TwoLineListItem has focus. Android supplies a standard layout resource for TwoLineListView (which does not include a selected item icon), but you can design your own custom XML layout for this object as shown here:

<?xml version="1.0" encoding="utf-8"?>
<!--
/*
 * Copyright (C) 2007 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-->

<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <ImageView android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/presence_offline"/>

    <TextView android:id="@android:id/text1"
        android:layout_marginTop="1dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/icon"
        android:textSize="15sp"
        android:textStyle="bold" />

    <TextView android:id="@android:id/text2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@android:id/text1"
        android:layout_alignLeft="@android:id/text1"
        android:paddingBottom="4dip"
        android:includeFontPadding="false"
        android:textSize="15sp"
        android:textStyle="normal" />

    <ImageView android:id="@android:id/selectedIcon"
        android:layout_marginTop="9dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginRight="7dip"
        android:src="@android:drawable/sym_action_call"/>
</TwoLineListItem>

Summary

XML Attributes

Attribute name Related methods  
android:mode    
XML Attributes inherited from class android.widget.RelativeLayout
XML Attributes inherited from class android.view.ViewGroup
XML Attributes inherited from class android.view.View
Constants inherited from class android.widget.RelativeLayout
Constants inherited from class android.view.ViewGroup
Constants inherited from class android.view.View
Fields inherited from class android.view.ViewGroup
Fields inherited from class android.view.View

Public Constructors

            TwoLineListItem(Context context)
            TwoLineListItem(Context context, AttributeSet attrs)
            TwoLineListItem(Context context, AttributeSet attrs, int defStyle)

Public Methods

          TextView  getText1()
Returns a handle to the item with ID text1.
          TextView  getText2()
Returns a handle to the item with ID text2.

Protected Methods

          void  onFinishInflate()
Finalize inflating a view from XML.
Methods inherited from class android.widget.RelativeLayout
Methods inherited from class android.view.ViewGroup
Methods inherited from class android.view.View
Methods inherited from class java.lang.Object
Methods inherited from interface android.graphics.drawable.Drawable.Callback
Methods inherited from interface android.view.KeyEvent.Callback
Methods inherited from interface android.view.ViewManager
Methods inherited from interface android.view.ViewParent

Details

XML Attributes

android:mode

Related Methods

Public Constructors

public TwoLineListItem(Context context)

public TwoLineListItem(Context context, AttributeSet attrs)

public TwoLineListItem(Context context, AttributeSet attrs, int defStyle)

Public Methods

public TextView getText1()

Returns a handle to the item with ID text1.

Returns

  • A handle to the item with ID text1.

public TextView getText2()

Returns a handle to the item with ID text2.

Returns

  • A handle to the item with ID text2.

Protected Methods

protected void onFinishInflate()

Finalize inflating a view from XML. This is called as the last phase of inflation, after all child views have been added.

Even if the subclass overrides onFinishInflate, they should always be sure to call the super method, so that we get called.

Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48