Rating bar like android in codename one

梦想与她 提交于 2020-07-23 11:47:27

问题


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..

Rating Bar


回答1:


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



回答2:


I'am not iOS developer but i can provide some links please try

1.DLStarRating

2.RatingBar

3.XLRatingBar

4.Sample RatingBar Project



来源:https://stackoverflow.com/questions/27600288/rating-bar-like-android-in-codename-one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!