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; // w w w. j av a 2s . com import android.content.Context; import android.util.AttributeSet; import android.widget.Checkable; import android.widget.LinearLayout; /** * Created by gautier on 16/03/2014. */ public class CheckableLinearLayout extends LinearLayout implements Checkable { private static final int[] CHECKED_STATE_SET = { android.R.attr.state_checked }; private boolean checked = false; public CheckableLinearLayout(Context context) { super(context); } public CheckableLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); } @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); } }