Back to project page ShareList-Android.
The source code is released under:
GNU General Public License
If you think the Android project ShareList-Android 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 org.mybop.sharelist.app.view.support; //from w w w . j a v a 2 s . c o m import android.content.Context; import android.util.AttributeSet; import android.widget.Checkable; import android.widget.RelativeLayout; /** * Created by gautier on 16/03/2014. */ public class CheckableRelativeLayout extends RelativeLayout implements Checkable { private static final int[] CHECKED_STATE_SET = { android.R.attr.state_checked }; private boolean checked = false; public CheckableRelativeLayout(Context context) { super(context); } public CheckableRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); } public CheckableRelativeLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected int[] onCreateDrawableState(int extraSpace) { final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); if (isChecked()) { mergeDrawableStates(drawableState, CHECKED_STATE_SET); } return drawableState; } @Override public void setChecked(boolean checked) { this.checked = checked; refreshDrawableState(); // //Propagate to childs // final int count = getChildCount(); // for (int i = 0; i < count; i++) { // final View child = getChildAt(i); // if (child instanceof Checkable) { // ((Checkable) child).setChecked(checked); // } // } } @Override public boolean isChecked() { return checked; } @Override public void toggle() { setChecked(!checked); } }