我有一个带有数组列表的微调器,它工作正常,但我想整理数据从 a 到 z(例如:苹果、球、猫、狗...)的顺序。我在下面提交我的代码
ArrayList<String> SourceArray = new ArrayList<String>();
Spinner Sourcespinner;// = new Spinner(this);
Sourcespinner = (Spinner)findViewById(R.id.Spinner1);
ArrayAdapter<String> SourceArrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item,SourceArray);
SourceArrayAdapter.add("Chennai");
SourceArrayAdapter.add("Mumbai");
SourceArrayAdapter.add("Kolkatta");
SourceArrayAdapter.add("Delhi");
Sourcespinner.setAdapter(SourceArrayAdapter);`
我不知道怎么排序
最佳答案
你可以用它来对你的数据进行排序
Collections.sort(SourceArray);
关于android - Android 中的 Spinner 数据排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11468547/