diff options
author | Amith Yamasani <yamasani@google.com> | 2009-07-31 07:24:08 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2009-07-31 07:24:08 -0700 |
commit | 498d90474b4208fd28cc2ae84d5759ddad7bfc0c (patch) | |
tree | a33b622dc4cf02d4c618bcc51ce4f973f694d74c /src/com/android/settings/IconPreferenceScreen.java | |
parent | 4c470091723e84dc894154a030f02b5153d286e5 (diff) | |
download | packages_apps_Settings-498d90474b4208fd28cc2ae84d5759ddad7bfc0c.zip packages_apps_Settings-498d90474b4208fd28cc2ae84d5759ddad7bfc0c.tar.gz packages_apps_Settings-498d90474b4208fd28cc2ae84d5759ddad7bfc0c.tar.bz2 |
Add an icon to the left of the settings at the top level.
Add a new attribute for the icon.
Add place holder icons.
Diffstat (limited to 'src/com/android/settings/IconPreferenceScreen.java')
-rw-r--r-- | src/com/android/settings/IconPreferenceScreen.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/com/android/settings/IconPreferenceScreen.java b/src/com/android/settings/IconPreferenceScreen.java new file mode 100644 index 0000000..c7c5303 --- /dev/null +++ b/src/com/android/settings/IconPreferenceScreen.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * 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. + */ + +package com.android.settings; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.drawable.Drawable; +import android.preference.Preference; +import android.util.AttributeSet; +import android.view.View; +import android.widget.ImageView; + +public class IconPreferenceScreen extends Preference { + + private Drawable mIcon; + + public IconPreferenceScreen(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public IconPreferenceScreen(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + setLayoutResource(R.layout.preference_icon); + TypedArray a = context.obtainStyledAttributes(attrs, + R.styleable.IconPreferenceScreen, defStyle, 0); + mIcon = a.getDrawable(R.styleable.IconPreferenceScreen_icon); + } + + @Override + public void onBindView(View view) { + super.onBindView(view); + ImageView imageView = (ImageView) view.findViewById(R.id.icon); + if (imageView != null && mIcon != null) { + imageView.setImageDrawable(mIcon); + } + } +} |