I have a TableRow containing String data displayed as minutes.
I want to order/sort that column data programmatically.
Is that possible? I really need that feature.

- 37,241
- 25
- 195
- 267

- 3,117
- 11
- 50
- 107
1 Answers
The image you showed does not look like a single TableRow
; in fact, it looks like 10.
Regardless, what you should do is keep a list of some kind with your data, and keep it sorted. An easy way to do this is keep a list of integers representing your minutes (in this case, 76, 84, 46, 68, 8, 9, 78, 78, 68, 46), then sort it. You can then re-fill your layout objects (whatever they are) with the sorted data.
ArrayList<Integer> minutes = new ArrayList<Integer>();
minutes.add(76);
minutes.add(84);
// ...
minutes.add(46);
Collections.sort(minutes);
Then, if you have your views already set up, you can reference each one using findViewById()
, and call setText()
on them to give them information, or create the views based on the data:
ViewGroup group = ...; // Might be a TableRow, LinearLayout, whatever...
group.removeAllViews();
for (Integer i : minutes) {
// Create a new view
yourView.setText(i + "'"); // Put it in 0' format
group.addView(yourView);
}
Then, your group
layout will contain a set of views representing your minutes
array.
For what it's worth, it would be better to use a ListView
here; this is what it was designed for.

- 66,919
- 24
- 133
- 141
-
1Dude, you're the best. I mark "Accepted" because i knew what is your technic/method. Applying it right now. Thank you very much bro :). – androniennn Dec 27 '12 at 02:01