Back to project page no-cloud-share.
The source code is released under:
GNU General Public License
If you think the Android project no-cloud-share 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 de.ub0r.android.nocloudshare.views; /*w w w .j a v a2 s . c o m*/ import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.widget.Checkable; import android.widget.RelativeLayout; /** * A checkable RelativeLayout. * * @author flx */ public class CheckableRelativeLayout extends RelativeLayout implements Checkable { private static final int[] STATE_CHECKABLE = {android.R.attr.state_checked}; private boolean mIsChecked; @SuppressWarnings("UnusedDeclaration") public CheckableRelativeLayout(final Context context) { super(context); } @SuppressWarnings("UnusedDeclaration") public CheckableRelativeLayout(final Context context, final AttributeSet attrs) { super(context, attrs); } @Override public boolean isChecked() { return mIsChecked; } @Override public void setChecked(final boolean checked) { mIsChecked = checked; setChecked(this, checked); refreshDrawableState(); } private void setChecked(final View child, final boolean checked) { if (child != this) { if (child instanceof Checkable) { ((Checkable) child).setChecked(checked); } child.setSelected(checked); } if (child instanceof ViewGroup) { ViewGroup vg = (ViewGroup) child; int l = vg.getChildCount(); for (int i = 0; i < l; i++) { setChecked(vg.getChildAt(i), checked); } } } @Override public void toggle() { setChecked(!mIsChecked); } @Override protected int[] onCreateDrawableState(final int extraSpace) { int[] drawableState = super.onCreateDrawableState(extraSpace + 1); if (mIsChecked) { mergeDrawableStates(drawableState, STATE_CHECKABLE); } return drawableState; } }