Joined
Last Online
Recent Posts
posted in 技术交流 read more

如题, 我想在悬浮窗中添加一个按钮"从相册选择图片", 并期望返回所选择的图片路径, 有大佬知道怎么实现吗?

posted in 技术交流 read more

已经解决了, 把数据复制一份进行修改, 再重新setDataSource就可以了

ui.run(function(){
    let window = floaty.rawWindow(
        <vertical w='*' bg='#FFFFFF'>
            <button id='add'>添加</button>
            <list id='todoList'>
                <vertical>
                    <text text='标题' textColor='#999999' textSize='12sp' />
                    <text text='{{this.title}}' textColor='#222222' textSize='14sp' />
                </vertical>
            </list>
        </vertical>
    );
    window.setSize(600, -2);
    window.setPosition(200, 200);
    let todoList = [{title: '测试1'}];
    ui.run(function() {
        window.todoList.setDataSource(todoList);
    })
    window.add.click(function() {
        ui.run(function() {
            let arr2 = todoList.concat();
            arr2.push({title: '测试' + Math.random()});
            todoList = arr2;
            window.todoList.setDataSource(todoList);
        })
    });
})
posted in 技术交流 read more

代码如下, 我想点击"添加"按钮的时候, 加入数据到list中显示, 但是执行的时候报错Only the original thread that created a view hierarchy can touch its views, 这个该如何操作呢?

let window = floaty.rawWindow(
    <vertical w='*' bg='#FFFFFF'>
        <button id='add'>添加</button>
        <list id='todoList'>
            <vertical>
                <text text='标题' textColor='#999999' textSize='12sp' />
                <text text='{{this.title}}' textColor='#222222' textSize='14sp' />
            </vertical>
        </list>
    </vertical>
);
window.setSize(600, -2);
window.setPosition(200, 200);
let todoList = [{title: '测试1'}];
ui.run(function() {
    window.todoList.setDataSource(todoList);
})
window.add.click(function() {
    ui.run(function() {
        todoList.push({title: '测试' + Math.random()});
    })
});

报错信息:

01:56:01.322/E: Wrapped android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. Expected: main Calling: ScriptThread-22[[remote]test1] (/android_asset/modules/__ui__.js#277)
Wrapped android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. Expected: main Calling: ScriptThread-22[[remote]test1]
    at /android_asset/modules/__ui__.js:277:0
    at /android_asset/modules/__ui__.js:271:0
    at /android_asset/modules/object-observe-lite.min.js:2:0
    at /android_asset/modules/object-observe-lite.min.js:2:0
    at /android_asset/modules/object-observe-lite.min.js:2:0
    at /android_asset/modules/object-observe-lite.min.js:2:0

posted in 技术交流 read more

升级版本到6.6.7没问题了,之前有问题的是6.5.3的版本

posted in 技术交流 read more

@ibozo 一样的哦,获取到的是84,我悬浮窗的y坐标设置为-84,还不能完全覆盖状态栏,实际值要是120才行

posted in 技术交流 read more

通过以下代码可以获取到状态栏的高度,但是我在红米K60手机上运行的结果是84(不准确),实际高度应该是120,有什么办法能获取到正确的高度吗?

function getStatueBarHeight() {
        let result = 0;
        let resourceId = context.getResources().getIdentifier("status_bar_height", "dimen",
                "android");
        if (resourceId > 0) {
            result = context.getResources().getDimensionPixelSize(resourceId);
        }
        return result;
    }
posted in 技术交流 read more

可以的, 要使用java的方式调用