1/* 2 * Copyright (C) 2010 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 com.android.quicksearchbox.preferences; 18 19import com.android.quicksearchbox.R; 20 21import android.content.Context; 22import android.graphics.drawable.Drawable; 23import android.preference.CheckBoxPreference; 24import android.view.View; 25import android.widget.ImageView; 26 27/** 28 * A CheckBoxPreference with an icon added. 29 */ 30public class SearchableItemPreference extends CheckBoxPreference { 31 32 private Drawable mIcon; 33 34 SearchableItemPreference(Context context) { 35 super(context); 36 setLayoutResource(R.layout.searchable_item_preference); 37 } 38 39 public void setIcon(Drawable icon) { 40 mIcon = icon; 41 } 42 43 @Override 44 protected void onBindView(View view) { 45 super.onBindView(view); 46 ImageView icon = (ImageView) view.findViewById(R.id.icon); 47 icon.setImageDrawable(mIcon); 48 } 49 50} 51