implement CompoundButton using GtkSwitch

This commit is contained in:
Julian Winkler
2024-02-15 21:08:13 +01:00
parent d2725a73c9
commit 2d6694d695
8 changed files with 306 additions and 13 deletions

View File

@@ -3,10 +3,8 @@ package android.widget;
import android.content.Context;
import android.util.AttributeSet;
public abstract class CompoundButton extends Button {
public abstract class CompoundButton extends Button implements Checkable {
private boolean checked;
public CompoundButton(Context context) {
super(context);
}
@@ -15,15 +13,24 @@ public abstract class CompoundButton extends Button {
super(context, attributeSet);
}
@Override
protected native long native_constructor(Context context, AttributeSet attrs);
public static interface OnCheckedChangeListener {}
public void setOnCheckedChangeListener(OnCheckedChangeListener listener) {}
public native void setOnCheckedChangeListener(OnCheckedChangeListener listener);
public void setChecked(boolean checked) {
this.checked = checked;
}
public native void setChecked(boolean checked);
public boolean isChecked() {
return checked;
}
public native boolean isChecked();
// following methods are overridden to prevent calling incompatible methods from superclasses
@Override
public void setOnClickListener(final OnClickListener l) {}
@Override
public void setText(CharSequence text) {}
@Override
public void setTextColor(int color) {}
@Override
public void setTextSize(float size) {}
}