这里是代码示例来面对我的问题。Codename One - 有没有办法避免点击时更改Button的UIID?
Container master, content;
Button lockButton;
void layout() {
master = new Container (new LayeredLayout());
content = new Container (BoxLayout.y());
content.setScrollableY (true);
lockButton = new Button ("");
lockButton.setUIID ("ButtonInvisible");
lockButton.addActionListener ((e)->{
unlock();
});
master.add(content);
}
void lock() {
master.add(lockButton);
}
void unlock() {
lockButton.remove();
}
ButtonInvisible 选择,未被选择和按压样式是相等的。
问题描述:
- 滚动
content
向下 - 调用
lock()
- 点击
content
(lockButton
截距点击) - 当按下指针
content
的滚动是0,上释放,它返回到之前的金额。
我想这会发生,因为按钮更改它是单击样式,这会导致重新绘制/重新验证基础内容的错误。
根据钻石的回答
信息更新:
集装箱master
是SwipeableContainer
中心部分。
无论何时打开SwipeableContainer
,都会调用方法lock()
。
如果我调用revalidate()
当SwipeableContainer
打开 - 屏幕奇怪地闪烁,但行为没有改变 - 每当按下按钮滚动仍然跳转到零。
也许是显著 - 有集装箱content
Tabs
组件在此版本的代码重新确认的不能是这种问题的一个原因,因为没有组件添加或移除,但问题仍然是相同的。
Container master, content;
Button lockButton;
void layout() {
master = new Container (new LayeredLayout());
content = new Container (BoxLayout.y());
content.setScrollableY (true);
lockButton = new Button ("");
lockButton.setUIID ("ButtonInvisible");
lockButton.addActionListener ((e)->{
unlock();
});
lockButton.setFocusable(false);
master.add(content).add(lockButton);
}
void lock() {
lockButton.setFocusable(true);
}
void unlock() {
swipeableContainer.close();
lockButton.setFocusable(false);
}
我发现这个问题很难从描述中理解。但是这里有几件事我可以说。按钮不会更改UIID。样式更改不会重新验证或影响滚动。一些截图或视频可以用来解释什么很快解释 –
感谢您的关注,我会尽可能快地提供视频。 –
这件事只发生在模拟器上,在设备上一切都很完美。抱歉。 –