评级栏,如android中的代号栏 [英] Rating bar like android in codename one

查看:82
本文介绍了评级栏,如android中的代号栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以一种类似于Android的代号形式添加添加竞赛栏。但是,恐怕没有一个可以在代号中创建的GUI了。还有其他创建方式吗?。

I want to add Add Raring Bar in a Form of codename one like android.. But am afraid there is no GUI for to create in codename one.. Is there any other option for to create it..

推荐答案

我认为有人在讨论论坛一次,但找不到链接。

I think someone contributed a component like that on the discussion forum once, but I can't find the link.

使用类似这样的东西创建应该相对简单(虽然没有测试此代码):

It should be relatively simple to create using something like this (didn't test this code though):

Container starSelect = new Container(new BoxLayout(BoxLayout.X_AXIS));
for(int iter = 0 ; iter < 5 ; iter++) {
    createStarButton(starSelect);
}

void createStarButton(final Container parent) {
    final CheckBox cb = new CheckBox();
    cb.setToggle(true);
    cb.setIcon(unselectedStarIcon);
    cb.setPressedIcon(selectedStarIcon);
    cb.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent ev) {
            if(cb.isSelected()) {
                boolean selected = true;
                for(int iter = 0 ; iter < parent.getComponentCount() ; iter++) {
                    Component current = parent.getComponentAt(iter);
                    if(current == cb) {
                       selected = false;
                       continue;
                    }
                    ((CheckBox)cb).setSelected(selected);
                }
            }
         }
    });
    parent.addComponent(cb);
}

这篇关于评级栏,如android中的代号栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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