手动触发拉动以刷新容器 [英] Manually trigger Pull to refresh on Container

查看:63
本文介绍了手动触发拉动以刷新容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我要在加载表格后手动触发代号为1的容器上的拉至刷新。请告知是否有任何想法。

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.

推荐答案

很简单,诀窍是使用 showListener 。假设这是起始代码(摘自《 Codename One开发人员指南》的部分拉刷新 ):

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

这篇关于手动触发拉动以刷新容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆