Skip to content

Instantly share code, notes, and snippets.

@msama
Last active June 23, 2016 11:59
Show Gist options
  • Save msama/6483209 to your computer and use it in GitHub Desktop.
Save msama/6483209 to your computer and use it in GitHub Desktop.
A checkable Android LinearLayout. This is useful for custom list rows.
package com.ahuralab.shakeacocktail.layouts;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.LinearLayout;
/**
* Allow custom list rows to be checked.
*
* @author msama (michele.sama@gmail.com) on 08/09/13.
* @author psaeedi on 08/09/13.
*/
public class CheckableLinearLayout extends LinearLayout implements Checkable {
private boolean checked;
public CheckableLinearLayout(Context context) {
super(context);
}
public CheckableLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CheckableLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void setChecked(boolean checked) {
this.checked = checked;
}
@Override
public boolean isChecked() {
return checked;
}
@Override
public void toggle() {
setChecked(!checked);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment