auto.js-ui项目配置保存

"ui";
ui.layout(
    <vertical padding="28">
        <ScrollView>
            <vertical>
                <input id="name1" hint="1" />
                <input id="name2" hint="2" />
                <input id="name3" hint="3" />
                <input id="name4" hint="4" />
                <input id="name10" hint="10" />
                <button id="ok" text="确定" />
            </vertical></ScrollView></vertical>);
var storage = storages.create("这个是一个文件名");
for (i = 0; i < 4; i++) {
    var content = storage.get("name" + (i + 1));
    
    if (content) {
        ui["name" + (i + 1)].setText(content);
    }
}

//指定确定按钮点击时要执行的动作
ui.ok.click(function () {
    arr = new Array();
    for (i = 0; i < 4; i++) {
        var content = ui["name" + (i + 1)].getText() + "";
        storage.put("name" + (i + 1), content);
        arr.push(content);
    } log(arr);
});

"ui";
ui.layout(
    <vertical >
        <Switch id="is1"/>
    </vertical>
    )
        ui.is1.on("click", function() {
        if (ui.is1.isChecked()) {
            log(1)
            files.write("///sdcard/i.dat", "true")
        } else {
            files.write("///sdcard/i.dat", "false")
        }
    })
    if (files.read("///sdcard/i.dat") == "true") {
        ui.is1.setChecked(true)
    } else {
        ui.is1.setChecked(false)
    }

你可能感兴趣的:(autojs)