我想列表項排序,我使用自定義列表視圖。在這我已經存儲在字符串數組中的項目。但在列出項目時,列表視圖顯示的是空項目而不是已排序的項目。但是,在調試時,字符串數組以有序格式存儲。如何解決它?如何在Android的自定義列表視圖列表中的項目進行排序?
3
A
回答
1
我所見過的代碼,我得到了下面的語句一些潛在的問題
HashMap<String, String> sampleObjectMap = new HashMap<String, String>();
titles[i-1]=**sampleObjectMap.put("title", dh.val1(i-1))**;
persons[i-1]=**sampleObjectMap.put("person", dh.pers(i-1))**;
priorities[i-1]=**sampleObjectMap.put("priorty", setpriority(String.valueOf(dh.getpriority(i-1))))**;
dates[i-1]=**sampleObjectMap.put("dat", getDate(Long.valueOf(dh.time(i-1)),"dd/MM/yyyy"))**;
這種大膽的聲明,將恢復以往任何映射的值與指定鍵或空,如果沒有這樣的映射。所以我假設在這種情況下以前沒有做過映射。所以請確保您數組填滿
+0
你是對的... –
4
/**
* need to sort the ArrayList based on Person’s firstName.
* Here inside the Collections.sort method we are
* implementing the Comparator interface and overriding the compare method.
*/
Collections.sort(employeeList, new Comparator(){
public int compare(Object o1, Object o2) {
ContactInfo p1 = (ContactInfo) o1;
ContactInfo p2 = (ContactInfo) o2;
return p1.getEmployeeName().compareToIgnoreCase(p2.getEmployeeName());
}
});
this.fav_adapter = new FavoritesAdapter(this, R.layout.favorite_list_view, employeeList);
setListAdapter(this.fav_adapter);
public class ContactInfo {
private String employeeLpn;
private String employeeName;
/**
* Gets value for employeeLpn
* @return the employeeLpn
*/
public String getEmployeeLpn() {
return employeeLpn;
}
/**
* Sets the value for employeeLpn
* @param employeeLpn the employeeLpn to set
*/
public void setEmployeeLpn(String employeeLpn) {
this.employeeLpn = employeeLpn;
}
/**
* Gets value for employeeName
* @return the employeeName
*/
public String getEmployeeName() {
return employeeName;
}
/**
* Sets the value for employeeName
* @param employeeName the employeeName to set
*/
public void setEmployeeName(String employeeName) {
this.employeeName = employeeName;
}
}
相關問題
- 1. Android:如何更新自定義列表視圖中的項目
- 2. 帶動態列表項目的自定義列表視圖Android
- 3. 自定義列表視圖自定義列表視圖Android
- 4. Android如何按列在列表視圖中對列表進行排序
- 5. 在Android自定義列表視圖中重複列表項
- 6. rails_admin - 如何按列表視圖中的自定義字段進行排序
- 7. 在列表視圖中對分組項目進行排序
- 8. 自定義列表視圖 - 排列項目
- 9. 如何使用自定義適配器在列表視圖中進行排序
- 10. 自定義列表視圖duplitcating項目
- 11. 自定義列表視圖項目
- 12. 從自定義列表視圖中的項目更新textView Android
- 13. 使用自定義列表視圖時訪問行項目android
- 14. 如何在kivy中創建自定義列表視圖項目?
- 15. android中的自定義列表視圖?
- 16. 自定義列表視圖中的Android
- 17. Android自定義列表視圖行
- 18. 如何自定義列表視圖行
- 19. 如何對列表框中的項目進行升序排序
- 20. Android使用自定義字體的列表視圖項目
- 21. Android從自定義列表視圖中訪問textView項目
- 22. 自定義列表視圖不顯示列表項目。
- 23. 來自自定義列表視圖中的項目
- 24. Android:自定義與基本適配器列表視圖:如何設置點擊列表中的行項目?
- 25. 自定義列表視圖multiselected的Android
- 26. Android的自定義列表視圖
- 27. 自定義列表視圖與自定義列表項目有微調
- 28. Android:如何根據日期對列表項目進行排序
- 29. Android:自定義列表視圖,適配器中的表視圖
- 30. 列表視圖項目排序
能否請您分享您的代碼? –
我試圖爲列表項目排序這是正確的,或者您正試圖存儲產品正確 –
我嘗試已存儲的列表項排序 –