| |||||||
Das Thema "ListActivity sortieren" befindet sich unter Android App Entwicklung auf Android-Hilfe.de.
|
| | Themen-Optionen | Ansicht |
| | #1 (permalink) |
| Android-Hilfe.de Mitglied Registriert seit: 06.07.2011
Beiträge: 71
Abgegebene Danke: 14
Erhielt 7 Danke für 7 Beiträge
| Desswegen hier mal ein Beispielcode: Code: import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class MyList extends ListActivity {
/** Called when the activity is first created. */
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Create an array of Strings, that will be put to our ListActivity
String[] names = new String[] { "Linux", "Windows7", "Eclipse", "Suse",
"Ubuntu", "Solaris", "Android", "iPhone"};
// Create an ArrayAdapter, that will actually make the Strings above
// appear in the ListView
this.setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, names));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// Get the item that was clicked
Object o = this.getListAdapter().getItem(position);
String keyword = o.toString();
Toast.makeText(this, "You selected: " + keyword, Toast.LENGTH_LONG)
.show();
}
} Und wie sorteirt man am besten Strings, selber implementieren muss ja bestimmt nicht sein? Wie funktioniert das genau mit dem Comparator? DANKE EUCH! Einen schoenen Abend noch Gruesse Soma |
| | |
| | #2 (permalink) |
| Android Guru Modell: Samsung Galaxy S (I9000) Registriert seit: 21.12.2009
Beiträge: 2.572
Abgegebene Danke: 76
Erhielt 506 Danke für 295 Beiträge
|
Arrays.sort()
__________________ Meine Apps: GTalk Widget free Filehosting mit direkt download links & ohne werbung |
| | |
![]() |
|
| Themen-Optionen | |
| Ansicht | |
| |
| ||||
| Thema | Autor | Forum | Antworten | Letzter Beitrag |
| Background von ListActivity | soma-web | Android App Entwicklung | 4 | 07.09.2011 22:30 |
| Probleme mit ListActivity [ getView ] | computer_freak | Android App Entwicklung | 2 | 31.05.2011 18:12 |
| ListActivity und OnGestureListener | icyground | Android App Entwicklung | 0 | 18.10.2010 15:36 |
| Problem mit ListActivity refresh | ping87 | Android App Entwicklung | 9 | 28.09.2010 02:03 |
| Bildschirm splitten: ListActivity / Button | tobias | Android App Entwicklung | 1 | 21.11.2009 21:10 |