android - 评分栏像代号一的android

标签 android ios codenameone

我想像android一样以codename one的形式添加Add Raring Bar..但是恐怕没有用于在codename one中创建的GUI..是否有任何其他选项可以创建它..

Rating Bar

最佳答案

我认为有人在 discussion forum 上贡献了类似的组件一次,但我找不到链接。

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

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 - 评分栏像代号一的android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27600288/

相关文章:

android - zIndex 不适用于 android

ios - swift 4 : Unrecognized selector sent to instance when calling a function inside another class

codenameone - 自定义搜索过滤器和日历代号一

java - 来自 json codenameone 的 ImageViewer 图像循环

android - Android 上的崩溃报告在开发者控制台中的位置

java - 我需要同步这个吗

java - Ant 公然忽略 JAVA_HOME 环境变量

ios - Xcode - 如何使用运行脚本将应用程序移出沙箱?

ios - 在 NSArray 中获取重复项

java - codenameone 中 canvas.drawColor 的替代函数是什么