mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Switch added
This commit is contained in:
32
ui/switch/switch.android.ts
Normal file
32
ui/switch/switch.android.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import observable = require("ui/core/observable");
|
||||
import view = require("ui/core/view");
|
||||
import application = require("application");
|
||||
|
||||
export class Switch extends view.View {
|
||||
private static checkedProperty = "checked";
|
||||
private _android: android.widget.Switch;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this._android = new android.widget.Switch(application.android.currentContext);
|
||||
}
|
||||
|
||||
get android(): android.widget.Switch {
|
||||
return this._android;
|
||||
}
|
||||
|
||||
get checked(): boolean {
|
||||
return this.android.isChecked();
|
||||
}
|
||||
set checked(value: boolean) {
|
||||
this.setProperty(Switch.checkedProperty, value);
|
||||
}
|
||||
|
||||
public setNativeProperty(data: observable.PropertyChangeData) {
|
||||
if (data.propertyName === Switch.checkedProperty) {
|
||||
this.android.setChecked(data.value);
|
||||
} else if (true) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user