I have got data from XML parsing, and try to sort it based on date which has format like "Wed, 06 Jun 2012 09:53:05 +0700". So all news from every provider will be mixed and organized from the latest to the newest.
Here is the code:
int i=0;
while (i<vec.size()){
row = new TableRowManager();
prov = new LabelField(((BinNews)vec.elementAt(i)).getProv(),DrawStyle.ELLIPSIS){
protected void paint(Graphics g) {
g.setColor(Color.ORANGERED);
super.paint(g);
}
};
title = new LabelField(((BinNews)vec.elementAt(i)).getTitle(),DrawStyle.ELLIPSIS){
protected void paint(Graphics g) {
g.setColor(Color.BLUE);
super.paint(g);
}
};
title.setFont(Font.getDefault().derive(Font.BOLD));
desc = new LabelField(((BinNews)vec.elementAt(i)).getDesc(),DrawStyle.ELLIPSIS){
protected void paint(Graphics g) {
g.setColor(Color.BLACK);
super.paint(g);
}
};
date = new LabelField(((BinNews)vec.elementAt(i)).getDate(),DrawStyle.ELLIPSIS){
protected void paint(Graphics g) {
g.setColor(Color.ORANGERED);
super.paint(g);
}
};
rows.addElement(row);
setSize(rows.size());
row.add(prov);
row.add(date);
row.add(title);
row.add(desc);
i++;
}
so, before I add it into the row, it will be sorted first. Can anyone help me?
try this -