Reputation: 4158
The code below is for saving friends list from facebook.
Profile[] f=user.getFriends();
for(int i=0;i<f.length;i++){
String id=f[i].getId();
String name=f[i].getName();
vector.addElement(new FriendsRequestObject(id,name));
}
Now i want to display the friends list with checkboxes.
VerticalFieldManager vfm=new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
boolean checked = false;
for(int i=0;i<vector.size();i++){
FriendsRequestObject co_vec = (FriendsRequestObject)vector.elementAt(i);
String name=co_vec.getSender_name();
String id=co_vec.getSender_id();
box = new CheckboxField(" "+name , checked, Field.USE_ALL_WIDTH){
public void paint(Graphics graphics) {
graphics.setColor(Color.WHITE);
super.paint(graphics);
}
};
box1.addElement(box);
// box.setMargin(6, 0, 0, 4);
vfm.add(box);
}
vfmMiddle.add(vfm);
How to arrange the List in Alphabetical order ?.
Upvotes: 0
Views: 203
Reputation: 8920
A simple way would be to use a SimpleSortingVector instead of a Vector, define and set the Comparitor you want to establish the desired order.
For an example have a look here.
Upvotes: 2