首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

沿袭CheckBoxPreference

2012-09-04 
继承CheckBoxPreferencepublic class DisabledAppearanceCheckboxPreference extends CheckBoxPreference

继承CheckBoxPreference

public class DisabledAppearanceCheckboxPreference extends CheckBoxPreference {?
?
? ? ? ? protected boolean mEnabledAppearance = false;?
?
? ? ? ? public DisabledAppearanceCheckboxPreference(Context context,?
? ? ? ? ? ? ? ? AttributeSet attrs) {?
? ? ? ? ? ? super(context, attrs);?
?
? ? ? ? }?
? ? @Override?
? ? protected void onBindView(View view) {?
? ? ? ? super.onBindView(view);?
? ? ? ? boolean viewEnabled = isEnabled()&&mEnabledAppearance;?
? ? ? ? enableView(view, viewEnabled);?
? ? }?
?
? ? protected void enableView( View view, boolean enabled){?
? ? ? ? view.setEnabled(enabled);?
? ? ? ? if ( view instanceof ViewGroup){?
? ? ? ? ? ? ViewGroup grp = (ViewGroup)view;?
? ? ? ? ? ? for ( int index = 0; index < grp.getChildCount(); index++)?
? ? ? ? ? ? ? ? enableView(grp.getChildAt(index), enabled);?
? ? ? ? }?
? ? }?
? ? public void setEnabledAppearance( boolean enabled){?
? ? ? ? mEnabledAppearance = enabled; ?
? ? ? ? notifyChanged();?
? ? }?
? ? @Override?
? ? protected void onClick() {?
? ? ? ? if ( mEnabledAppearance)?
? ? ? ? ? ? super.onClick();?
? ? ? ? else{?
? ? ? ? ? ? //展示其他东西??????? }?
? ? }?
?
}?

热点排行