如何解决在应用程序中加载单选按钮选择的延迟?
How to solve the delay in loading the radio button selection in the application?
在我的应用程序中,我选择了一个单选按钮字段。当我打开页面时,所选字段有一些延迟。示例:我正在打开页面,该单选按钮处于未选中状态,一段时间后(比如悬停在 screen/scrolling 上)单选按钮变为选中状态。有没有其他方法可以解决这个延迟?
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
statementGroupSelectionModel.setSelected(item, profile.getSelected());
}
});
在上面的代码中,"item" 是小部件字段名称,根据我的 "getselected" 值,将选择单选图标。这里我的 "getSelected" 值为真。
scheduleDeferred
中的任何代码都将推迟执行,直到浏览器完成页面渲染和流程控制 returns 到 Javascript 事件循环,如 [=22] 中所述=]:
Deferring some logic into the immediate future: the Scheduler class
Sometimes you want to break up your logic loop so that the JavaScript event loop gets a chance to run between two pieces of code. The Scheduler
class will allow you to do that. The logic that you pass to Scheduler will run at some point in the future, after control has been returned to the JavaScript event loop. This little delay may give the interface a chance to process some user events or initialize other code. To use the Scheduler
class in its simplest form, you create a subclass of the Command
class, overriding the execute()
method and pass it to Scheduler.scheduleDeferred
如果您想要立即选中单选按钮,只需移除 Scheduler
包装,即将 statementGroupSelectionModel.setSelected(item, profile.getSelected());
移出 scheduleDeferred
.
// Put this here
statementGroupSelectionModel.setSelected(item, profile.getSelected());
// Remove the following code
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
...
});
如果你想要的不是那个(抱歉,你的解释很不清楚),只是为了能够自己设置延迟时间而不必等待浏览器,你可以使用 Timer
class 这在上面链接的文档中有解释。
在我的应用程序中,我选择了一个单选按钮字段。当我打开页面时,所选字段有一些延迟。示例:我正在打开页面,该单选按钮处于未选中状态,一段时间后(比如悬停在 screen/scrolling 上)单选按钮变为选中状态。有没有其他方法可以解决这个延迟?
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
statementGroupSelectionModel.setSelected(item, profile.getSelected());
}
});
在上面的代码中,"item" 是小部件字段名称,根据我的 "getselected" 值,将选择单选图标。这里我的 "getSelected" 值为真。
scheduleDeferred
中的任何代码都将推迟执行,直到浏览器完成页面渲染和流程控制 returns 到 Javascript 事件循环,如 [=22] 中所述=]:
Deferring some logic into the immediate future: the Scheduler class
Sometimes you want to break up your logic loop so that the JavaScript event loop gets a chance to run between two pieces of code. TheScheduler
class will allow you to do that. The logic that you pass to Scheduler will run at some point in the future, after control has been returned to the JavaScript event loop. This little delay may give the interface a chance to process some user events or initialize other code. To use theScheduler
class in its simplest form, you create a subclass of theCommand
class, overriding theexecute()
method and pass it toScheduler.scheduleDeferred
如果您想要立即选中单选按钮,只需移除 Scheduler
包装,即将 statementGroupSelectionModel.setSelected(item, profile.getSelected());
移出 scheduleDeferred
.
// Put this here
statementGroupSelectionModel.setSelected(item, profile.getSelected());
// Remove the following code
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
...
});
如果你想要的不是那个(抱歉,你的解释很不清楚),只是为了能够自己设置延迟时间而不必等待浏览器,你可以使用 Timer
class 这在上面链接的文档中有解释。