根据android中web服务的日期对listview进行排序
我有一个来自web服务的listview,它的名称和日期是每行的列表项。我需要在android中根据日期对这个listview进行排序。我该怎么做 我使用的代码: 受保护的字符串doInBackground(字符串…args){根据android中web服务的日期对listview进行排序,android,Android,我有一个来自web服务的listview,它的名称和日期是每行的列表项。我需要在android中根据日期对这个listview进行排序。我该怎么做 我使用的代码: 受保护的字符串doInBackground(字符串…args){ for(int i=0;ivalue map.put(Constants.REQUEST_ID,webCall.parser.getValue(e,“name”)); map.put(Constants.KEY_DATE,webCall.parser.getValue
for(int i=0;ivalue
map.put(Constants.REQUEST_ID,webCall.parser.getValue(e,“name”));
map.put(Constants.KEY_DATE,webCall.parser.getValue(e,“DATE”));
//将哈希列表添加到ArrayList
menuItems.add(地图);
}
返回null;
}
受保护的void onPostExecute(字符串文件\u url){
//获取所有产品后关闭对话框
//从后台线程更新UI
runOnUiThread(新的Runnable(){
公开募捐{
ListAdapter=new SimpleAdapter(此,菜单项,R.layout.list_项,新字符串[]){
Constants.REQUEST\u ID、Constants.KEY\u日期
},new int[]{
R.id.id,R.id.name});
setListAdapter(适配器);
谢谢
util.array.sort(myArray);
你是从数据库中获取数据的吗?请看我上面的代码。你可以提供一些参考或代码。你提到的三点是显而易见的。
for (int i = 0; i < nl.getLength(); i++) {
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element) nl.item(i);
// adding each child node to HashMap key => value
map.put(Constants.REQUEST_ID, webCall.parser.getValue(e, "name"));
map.put(Constants.KEY_DATE, webCall.parser.getValue(e, "Date"));
// adding HashList to ArrayList
menuItems.add(map);
}
return null;
}
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
ListAdapter adapter = new SimpleAdapter(this,menuItems, R.layout.list_item, new String[] {
Constants.REQUEST_ID, Constants.KEY_DATE
}, new int[] {
R.id.id, R.id.name});
setListAdapter(adapter);