blob: 5606c60c3b98aadf0b7dd92ae00b2a0a8f9adc5b [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.widget;
18
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080019import android.annotation.Widget;
20import android.content.Context;
21import android.content.res.TypedArray;
22import android.util.AttributeSet;
Svetoslav Ganov8a78fd42012-01-17 14:36:46 -080023import android.view.accessibility.AccessibilityEvent;
24import android.view.accessibility.AccessibilityNodeInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025import android.widget.RelativeLayout;
26
27/**
28 * <p>A view group with two children, intended for use in ListViews. This item has two
29 * {@link android.widget.TextView TextViews} elements (or subclasses) with the ID values
30 * {@link android.R.id#text1 text1}
31 * and {@link android.R.id#text2 text2}. There is an optional third View element with the
32 * ID {@link android.R.id#selectedIcon selectedIcon}, which can be any View subclass
33 * (though it is typically a graphic View, such as {@link android.widget.ImageView ImageView})
34 * that can be displayed when a TwoLineListItem has focus. Android supplies a
35 * {@link android.R.layout#two_line_list_item standard layout resource for TwoLineListView}
36 * (which does not include a selected item icon), but you can design your own custom XML
Dianne Hackborn1ca6a1c2009-03-27 19:19:20 -070037 * layout for this object.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038 *
39 * @attr ref android.R.styleable#TwoLineListItem_mode
Romain Guy86ca5d32012-07-03 17:23:30 -070040 *
41 * @deprecated This class can be implemented easily by apps using a {@link RelativeLayout}
42 * or a {@link LinearLayout}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043 */
Romain Guy86ca5d32012-07-03 17:23:30 -070044@Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045@Widget
46public class TwoLineListItem extends RelativeLayout {
47
48 private TextView mText1;
49 private TextView mText2;
50
51 public TwoLineListItem(Context context) {
52 this(context, null, 0);
53 }
54
55 public TwoLineListItem(Context context, AttributeSet attrs) {
56 this(context, attrs, 0);
57 }
58
Alan Viverette617feb92013-09-09 18:09:13 -070059 public TwoLineListItem(Context context, AttributeSet attrs, int defStyleAttr) {
60 this(context, attrs, defStyleAttr, 0);
61 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080062
Alan Viverette617feb92013-09-09 18:09:13 -070063 public TwoLineListItem(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
64 super(context, attrs, defStyleAttr, defStyleRes);
65
66 final TypedArray a = context.obtainStyledAttributes(
67 attrs, com.android.internal.R.styleable.TwoLineListItem, defStyleAttr, defStyleRes);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068
69 a.recycle();
70 }
71
72 @Override
73 protected void onFinishInflate() {
74 super.onFinishInflate();
75
76 mText1 = (TextView) findViewById(com.android.internal.R.id.text1);
77 mText2 = (TextView) findViewById(com.android.internal.R.id.text2);
78 }
79
80 /**
81 * Returns a handle to the item with ID text1.
82 * @return A handle to the item with ID text1.
83 */
84 public TextView getText1() {
85 return mText1;
86 }
87
88 /**
89 * Returns a handle to the item with ID text2.
90 * @return A handle to the item with ID text2.
91 */
92 public TextView getText2() {
93 return mText2;
94 }
Svetoslav Ganov8a78fd42012-01-17 14:36:46 -080095
96 @Override
97 public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
98 super.onInitializeAccessibilityEvent(event);
99 event.setClassName(TwoLineListItem.class.getName());
100 }
101
102 @Override
103 public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
104 super.onInitializeAccessibilityNodeInfo(info);
105 info.setClassName(TwoLineListItem.class.getName());
106 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800107}