Codename One工具栏中的无限旋转命令(或按钮)

时间:2016-01-27 22:12:04

标签: java toolbar codenameone infinite

我想'无限'旋转Codename One Toolbar中的命令(刷新命令)(直到加载完成,然后我想停止旋转,但图像仍然必须是可见的)。我可以更改图标以便开始旋转吗?我怎样才能达到这个结果?

旋转图标在旋转时不应该是可点击的,但这不应该难以实现。

1 个答案:

答案 0 :(得分:3)

您可以使用工具栏API和一点点黑客攻击。我创建了以下方法:

private Command myCommand = new Command("");
Form f = new Form("Test form");
Toolbar t = new Toolbar();
f.setToolbar(t);

Command back = new Command("Back") {

    @Override
    public void actionPerformed(ActionEvent evt) {
       //Do stuff
    }
};
back.putClientProperty("uiid", "BackCommand");
f.setBackCommand(back);
t.addCommandToLeftBar(back);

myCommand = new Command(YourProgressImage) {

    @Override
    public void actionPerformed(ActionEvent evt) {
        //To show the progress when some actions are being performed 
        showTitleProgress(t);
        //When you're done, discard the progress and restore your command
        hideTitleProgress(t, myCommand);
    }
}
myCommand.putClientProperty("TitleCommand", true);
t.addCommandToRightBar(myCommand);
f.show();

将它与工具栏API和您的表单一起使用,如下所示:

MyListWidget::MyListWidget(QWidget* parent)
    : QListWidget(parent)
{
    QItemSelectionModel* oldSelectionModel = selectionModel();
    QItemSelectionModel* newSelectionModel = new QItemSelectionModel(model(), oldSelectionModel->parent());
    setSelectionModel(newSelectionModel);
    oldSelectionModel->deleteLater();
}