如果我想在加载表单后手动触发 Codename One 中的 Container 上的 Pull to Refresh。请告知是否有人有任何想法。
最佳答案
很简单,诀窍是使用 showListener
.假设这是起始代码(取自 Codename One Developer Guide, section "Pull to refresh" ):
Form hi = new Form("Pull To Refresh", BoxLayout.y());
hi.getContentPane().addPullToRefresh(() -> {
hi.add("Pulled at " + L10NManager.getInstance().formatDateTimeShort(new Date()));
});
hi.show();
要在加载表单后调用“Pull to Refresh”监听器,您可以这样做:
Form hi = new Form("Pull To Refresh", BoxLayout.y());
Runnable myRunnable = () -> {
hi.add("Pulled at " + L10NManager.getInstance().formatDateTimeShort(new Date()));
};
hi.getContentPane().addPullToRefresh(() -> {
myRunnable.run();
});
hi.addShowListener(l -> {
myRunnable.run();
});
hi.show();
关于codenameone - 手动触发 Pull 刷新容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51183183/