Back to project page cosmic_hub.
The source code is released under:
GNU General Public License
If you think the Android project cosmic_hub listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.cosmic.mods; /*from w w w . j a v a 2 s . c o m*/ import com.cosmic.mods.R; 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_icon1); } @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); } } public void setIcon(Drawable icon) { if ((icon == null && mIcon != null) || (icon != null && !icon.equals(mIcon))) { mIcon = icon; notifyChanged(); } } public Drawable getIcon() { return mIcon; } }