wangzhibo
4 天以前 ae6f40460dcd56af6c5f60ba52c883854c3bac55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.mobeta.android.dslv;
 
import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.LinearLayout;
 
public class CheckableLinearLayout extends LinearLayout implements Checkable {
 
    private static final int CHECKABLE_CHILD_INDEX = 0;
    private Checkable child;
 
    public CheckableLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
 
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        child = (Checkable) getChildAt(CHECKABLE_CHILD_INDEX);
    }
 
    @Override
    public boolean isChecked() {
        return child.isChecked(); 
    }
 
    @Override
    public void setChecked(boolean checked) {
        child.setChecked(checked);
    }
 
    @Override
    public void toggle() {
        child.toggle();
    }
    
}