动态UI问题,请作者大大回复

[复制链接]
查看1171 | 回复1 | 2021-11-1 13:12:45 | 显示全部楼层 |阅读模式

问题1: 用线程阻塞的办法,动态UI在界面点击继续之后,ui.getData() 参数返回值为空
ui.newLayout("layout1")
ui.newRow("layout1","row1")
ui.addEditText("layout1","editId1","中国牛逼")
ui.newRow("layout1","row2")
ui.loadProfile("/sdcard/myui.txt")
ui.setOnClose("layout1","onClose()")
function onClose()
        ui.saveProfile("/sdcard/myui.txt")
    close = true
end
close = false
ui.show("layout1")


while close == false do
        sleep(500)
end
print("ui data==",ui.getData())



问题2:同样是使用阻塞线程的办法,添加一个Button开关闭布局窗口,返回值还是空的
ui.newLayout("layout1")
ui.newRow("layout1","row1")
ui.addEditText("layout1","editId1","中国牛逼")
ui.newRow("layout1","row2")
ui.addButton("layout1","btnnId1","开始运行")
ui.loadProfile("/sdcard/myui.txt")
ui.setOnClick("btnnId1","onClick()")
close = false
function onClick()
        ui.saveProfile("/sdcard/myui.txt")
    ui.dismiss("layout1")
    close = true
end
ui.show("layout1",false)


while close == false do
        sleep(500)
end
print("ui data==",ui.getData())



只有当主线程主动关闭布局,才能取到返回值。请问下上面异步关闭窗口有什么办法可以获取到返回值,并且可以在后续的代码修改UI配置
ui.newLayout("layout1")
ui.newRow("layout1","row1")
ui.addEditText("layout1","editId1","中国牛逼")
ui.newRow("layout1","row2")
ui.addButton("layout1","btnnId1","开始运行")
ui.loadProfile("/sdcard/myui.txt")


ui.show("layout1",false)


sleep(1000)
ui.saveProfile("/sdcard/myui.txt")
print("ui data==",ui.getData())




回复

使用道具 举报

flk100207 | 2021-11-1 14:02:12 | 显示全部楼层
          只要有图灵

         生活就有希望
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1

主题

7

帖子

33

积分

新手上路

Rank: 1

积分
33