Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2012 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 package android.preference2.cts;
     17 
     18 import android.preference2.cts.R;
     19 
     20 import android.content.Context;
     21 import android.content.res.TypedArray;
     22 import android.graphics.drawable.Drawable;
     23 import android.preference.EditTextPreference;
     24 import android.util.AttributeSet;
     25 
     26 public class CustomEditTextPreference extends EditTextPreference {
     27     private Drawable mIcon;
     28     private String mTitle;
     29     public CustomEditTextPreference(Context context, AttributeSet attrs) {
     30         super(context, attrs);
     31         init(attrs);
     32         setIcon(mIcon);
     33         this.setTitle(mTitle);
     34     }
     35 
     36     public CustomEditTextPreference(Context context) {
     37         super(context);
     38     }
     39 
     40     public CustomEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
     41         super(context, attrs, defStyle);
     42         init(attrs);
     43         setIcon(mIcon);
     44         this.setTitle(mTitle);
     45     }
     46 
     47     private void init(AttributeSet attrs) {
     48         TypedArray a = getContext().obtainStyledAttributes(attrs,R.styleable.CustPref);
     49         mTitle =a.getString(R.styleable.CustPref_title);
     50         mIcon  = a.getDrawable(R.styleable.CustPref_icon);
     51     }
     52 }
     53