嗨大家我是android的新手,我想知道如何对来自Json String的数据进行排序。 这是获取Json的密钥和值的代码并将其存储在Wheel Adapter中。它在WheelAdapter中显示数据但不在升序中显示。
MainActivity.java
-------------------
JSONObject jObject;
String stradptr[];
private boolean wheelScrolled = false;
ArrayWheelAdapter<String> adapter;
try {
String str = getResponseText("http://www.credit-direct.be/Application/Webservice/GetRates.php?type=PAT");
jObject = new JSONObject(str);
Log.i("TRY", "COMMING");
Iterator iter = jObject.keys();
stradptr = new String[20];
Log.i("ITRETER", "COMMING");
int i = 0;
while (iter.hasNext()) {
String key = (String) iter.next();
String value = jObject.getString(key);
stradptr[i++] = key + " mois - " + value;
Log.v(key, value);
}
} catch (Exception e) {
e.printStackTrace();
}
wheel = (WheelView) findViewById(R.id.wheelView1);
initWheel1(R.id.wheelView1);
}
// initWheel1 Method...
private void initWheel1(int id) {
WheelView wheel = (WheelView) findViewById(id);
adapter = new ArrayWheelAdapter<String>(getApplicationContext(),
stradptr);
// Arrays.sort(stradptr);
adapter.setTextSize(20);
wheel.setViewAdapter(adapter);
wheel.setCurrentItem(0);
wheel.addChangingListener(changedListener);
wheel.addScrollingListener(scrolledListener);
}