Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Java by T-Rex ( 14 years ago )
package com.androidhub.core;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.LinearLayout;

public class CheckableLinearLayout extends LinearLayout implements Checkable {
 private boolean checked = false;

 public CheckableLinearLayout(Context context) {
     super(context, null);
 }

 public CheckableLinearLayout(Context context, AttributeSet attrs) {
     super(context, attrs);       
 }

 private static final int[] CheckedStateSet = {
     android.R.attr.state_checked
 };

 public void setChecked(boolean b) {
     checked = b;
 }

 public boolean isChecked() {
     return checked;
 }

 public void toggle() {
     checked = !checked;
 }

 @Override
 protected int[] onCreateDrawableState(int extraSpace) {
     final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
     if (isChecked()) {
         mergeDrawableStates(drawableState, CheckedStateSet);
     }
     return drawableState;
 }

 @Override
 public boolean performClick() {
     toggle();
     return super.performClick();
 }
}

 

Revise this Paste

Your Name: Code Language: