Manually trigger Pull to refresh on Container

故事扮演 提交于 2019-12-10 13:55:09

问题


If I want to manually trigger Pull to Refresh on Container in Codename One after the load of the form. Please advise if anyone have any idea.


回答1:


It's easy, the trick is the use of the showListener. Suppose that this is the starting code (taken from the 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();

To invoke the "Pull to Refresh" listener after the load of the Form, you can do so:

    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();


来源:https://stackoverflow.com/questions/51183183/manually-trigger-pull-to-refresh-on-container

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!