OSDN Git Service

Remove unnecessary casts on calls to findViewById
[android-x86/frameworks-base.git] / core / java / android / widget / TwoLineListItem.java
1 /*
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
17 package android.widget;
18
19 import android.annotation.Widget;
20 import android.content.Context;
21 import android.content.res.TypedArray;
22 import android.util.AttributeSet;
23
24 /**
25  * <p>A view group with two children, intended for use in ListViews. This item has two
26  * {@link android.widget.TextView TextViews} elements (or subclasses) with the ID values
27  * {@link android.R.id#text1 text1}
28  * and {@link android.R.id#text2 text2}. There is an optional third View element with the
29  * ID {@link android.R.id#selectedIcon selectedIcon}, which can be any View subclass
30  * (though it is typically a graphic View, such as {@link android.widget.ImageView ImageView})
31  * that can be displayed when a TwoLineListItem has focus. Android supplies a
32  * {@link android.R.layout#two_line_list_item standard layout resource for TwoLineListView}
33  * (which does not include a selected item icon), but you can design your own custom XML
34  * layout for this object.
35  *
36  * @attr ref android.R.styleable#TwoLineListItem_mode
37  *
38  * @deprecated This class can be implemented easily by apps using a {@link RelativeLayout}
39  * or a {@link LinearLayout}.
40  */
41 @Deprecated
42 @Widget
43 public class TwoLineListItem extends RelativeLayout {
44
45     private TextView mText1;
46     private TextView mText2;
47
48     public TwoLineListItem(Context context) {
49         this(context, null, 0);
50     }
51
52     public TwoLineListItem(Context context, AttributeSet attrs) {
53         this(context, attrs, 0);
54     }
55
56     public TwoLineListItem(Context context, AttributeSet attrs, int defStyleAttr) {
57         this(context, attrs, defStyleAttr, 0);
58     }
59
60     public TwoLineListItem(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
61         super(context, attrs, defStyleAttr, defStyleRes);
62
63         final TypedArray a = context.obtainStyledAttributes(
64                 attrs, com.android.internal.R.styleable.TwoLineListItem, defStyleAttr, defStyleRes);
65
66         a.recycle();
67     }
68
69     @Override
70     protected void onFinishInflate() {
71         super.onFinishInflate();
72
73         mText1 = findViewById(com.android.internal.R.id.text1);
74         mText2 = findViewById(com.android.internal.R.id.text2);
75     }
76
77     /**
78      * Returns a handle to the item with ID text1.
79      * @return A handle to the item with ID text1.
80      */
81     public TextView getText1() {
82         return mText1;
83     }
84
85     /**
86      * Returns a handle to the item with ID text2.
87      * @return A handle to the item with ID text2.
88      */
89     public TextView getText2() {
90         return mText2;
91     }
92
93     @Override
94     public CharSequence getAccessibilityClassName() {
95         return TwoLineListItem.class.getName();
96     }
97 }