Google是如何实现视图的,例如ToggleButton

时间:2018-02-11 08:54:32

标签: android

我试图制作自定义视图,我想实现一个界面 public class PokerCardView extends CardView implements Checkable

所以我想查看Google如何实现Checkable接口,我找到了 public abstract class CompoundButton extends Button implements Checkable

但是当我打开CompoundButton.class时,我没有看到任何有意义的代码,看来这个文件中的所有方法只做一件事,throw new RuntimeException("Stub!")。 与ToggleButton.class相同

那么我在哪里可以找到实现Checkable的真实代码,例如setChecked(),toggle()。

// CompoundButton.class
public abstract class CompoundButton extends Button implements Checkable {
public CompoundButton(Context context) {
    super((Context)null, (AttributeSet)null, 0, 0);
    throw new RuntimeException("Stub!");
}

public CompoundButton(Context context, AttributeSet attrs) {
    super((Context)null, (AttributeSet)null, 0, 0);
    throw new RuntimeException("Stub!");
}

public CompoundButton(Context context, AttributeSet attrs, int defStyleAttr) {
    super((Context)null, (AttributeSet)null, 0, 0);
    throw new RuntimeException("Stub!");
}

public CompoundButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super((Context)null, (AttributeSet)null, 0, 0);
    throw new RuntimeException("Stub!");
}

public void toggle() {
    throw new RuntimeException("Stub!");
}

public boolean performClick() {
    throw new RuntimeException("Stub!");
}

@ExportedProperty
public boolean isChecked() {
    throw new RuntimeException("Stub!");
}

public void setChecked(boolean checked) {
    throw new RuntimeException("Stub!");
}

public void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener listener) {
    throw new RuntimeException("Stub!");
}

public void setButtonDrawable(int resId) {
    throw new RuntimeException("Stub!");
}

public void setButtonDrawable(Drawable drawable) {
    throw new RuntimeException("Stub!");
}

public Drawable getButtonDrawable() {
    throw new RuntimeException("Stub!");
}

public void setButtonTintList(ColorStateList tint) {
    throw new RuntimeException("Stub!");
}

public ColorStateList getButtonTintList() {
    throw new RuntimeException("Stub!");
}

public void setButtonTintMode(Mode tintMode) {
    throw new RuntimeException("Stub!");
}

public Mode getButtonTintMode() {
    throw new RuntimeException("Stub!");
}

public CharSequence getAccessibilityClassName() {
    throw new RuntimeException("Stub!");
}

public int getCompoundPaddingLeft() {
    throw new RuntimeException("Stub!");
}

public int getCompoundPaddingRight() {
    throw new RuntimeException("Stub!");
}

protected void onDraw(Canvas canvas) {
    throw new RuntimeException("Stub!");
}

protected int[] onCreateDrawableState(int extraSpace) {
    throw new RuntimeException("Stub!");
}

protected void drawableStateChanged() {
    throw new RuntimeException("Stub!");
}

public void drawableHotspotChanged(float x, float y) {
    throw new RuntimeException("Stub!");
}

protected boolean verifyDrawable(Drawable who) {
    throw new RuntimeException("Stub!");
}

public void jumpDrawablesToCurrentState() {
    throw new RuntimeException("Stub!");
}

public Parcelable onSaveInstanceState() {
    throw new RuntimeException("Stub!");
}

public void onRestoreInstanceState(Parcelable state) {
    throw new RuntimeException("Stub!");
}

public void onProvideAutofillStructure(ViewStructure structure, int flags) {
    throw new RuntimeException("Stub!");
}

public void autofill(AutofillValue value) {
    throw new RuntimeException("Stub!");
}

public int getAutofillType() {
    throw new RuntimeException("Stub!");
}

public AutofillValue getAutofillValue() {
    throw new RuntimeException("Stub!");
}

public interface OnCheckedChangeListener {
    void onCheckedChanged(CompoundButton var1, boolean var2);
}
}

1 个答案:

答案 0 :(得分:0)

您应该在SDK管理器中下载源代码。