问题
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..
回答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