评级栏就像android一样代号

时间:2014-12-22 09:56:42

标签: android ios codenameone

我想以代号的形式添加添加Raring Bar,例如android ..但是我担心没有GUI可以用代号创建一个..是否还有其他选项可以创建它..

Rating Bar

2 个答案:

答案 0 :(得分:2)

我认为有人在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.setToggleButton(
    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);
}

答案 1 :(得分:0)

我不是iOS开发者,但我可以提供一些链接,请尝试

1。DLStarRating

2。RatingBar

3。XLRatingBar

4。Sample RatingBar Project

相关问题