D
DeNiXP
Neues Mitglied
- 0
Hallo,
ich hab ein Problem mit der Sortierung von einer Arrayliste.
Ich habe eine XML Datei die ich geparst habe und mir den Titel, das Datum und die Beschreibung in ein Textview auslesen lasse.
Das Sortieren nach dem Titel funktioniert problemlos, jedoch möchte ich jetzt gern die Arraylist nach Datum und der Bescheibung sortieren.
Kann mir jemand helfen ? Wie kann ich die Daten so sortieren, dass der Aufbau bei der Anzeige, die selbe bleibt ?
Hier ist mein bisheriger Code..
ich hab ein Problem mit der Sortierung von einer Arrayliste.
Ich habe eine XML Datei die ich geparst habe und mir den Titel, das Datum und die Beschreibung in ein Textview auslesen lasse.
Das Sortieren nach dem Titel funktioniert problemlos, jedoch möchte ich jetzt gern die Arraylist nach Datum und der Bescheibung sortieren.
Kann mir jemand helfen ? Wie kann ich die Daten so sortieren, dass der Aufbau bei der Anzeige, die selbe bleibt ?
Titel
Bescheibung (Datum)
Hier ist mein bisheriger Code..
Code:
[SIZE=2][COLOR=#7f0055][B][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/B]
[LEFT][/COLOR][/SIZE][SIZE=2]List<RSSItem> [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]items[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/COLOR][/SIZE][/COLOR][/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onCreate(Bundle savedInstanceState) {[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2].onCreate(savedInstanceState);[/SIZE]
[SIZE=2]setContentView(R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]main[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
[SIZE=2]loadFeed();[/SIZE][/LEFT]
[/LEFT]
[LEFT][SIZE=2]} [/SIZE]
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// XML [U]Parsen[/U][/COLOR][/SIZE][/COLOR][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] loadFeed() {[/SIZE][/LEFT]
[/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]try[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] {[/SIZE]
[LEFT][SIZE=2]FeedParser parser = [/SIZE][/LEFT]
[/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] FeedParser([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2].getResources().getXml(R.xml.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]badeseenliste[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]));[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]long[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] start = System.[I]currentTimeMillis[/I]();[/SIZE]
[LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]items[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = parser.parse();[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]long[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] duration = System.[I]currentTimeMillis[/I]() - start;[/SIZE]
[SIZE=2]Log.[I]i[/I]([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"SeenAtlas"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Parser duration="[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + duration);[/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//pubDate[/COLOR][/SIZE][/COLOR][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] List<String> titles = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ArrayList<String>([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]items[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].size());[/SIZE][/LEFT]
[/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] RSSItem item : [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]items[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) {[/SIZE]
[LEFT][SIZE=2]titles.add(item.getTitle() + [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + item.getDescription() + [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]" \t ("[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + item.getPubDate()+ [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]")"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE][/LEFT]
[/LEFT]
[LEFT][SIZE=2]Collections.[I]sort[/I](titles);[/SIZE][/LEFT]
[LEFT][SIZE=2]}[/SIZE][/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2].setListAdapter([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ArrayAdapter<String>([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]row[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], titles));[/SIZE]
[SIZE=2]}[/SIZE][/LEFT]
Danke im vorraus