我想與一個看似複雜的HashMap對象一起使用來在Android中使我的可展開Listview工作。排序一個完整的HashMap
我的HashMap的通用參數,如下圖所示:
//HashMap<Map<YEAR,MONTH>,List<DAYS>>
HashMap<Map<Integer,Integer>,List<Integer>
我使用哈希表來監控日,月,年的時候發生了一件大事。因此,假設在事件發生在12日,20日和25位2013年5月,我會做一些事情,因爲這:
HashMap<Integer,Integer>,List<Integer>> events = new HashMap<Integer,Integer>,List<Integer>();
HashMap<Integer,Integer> yearMonth = new HashMap<Integer,Integer>();
yearMonth.put(2013,5);
events.put(yearMonth,Arrays.asList(new Integer[]{12,20,25}));
我已經創建了一個適配器,我可擴展列表視圖,如下圖所示它顯示的罰款。現在我希望能夠按年份和月份排序上面的HashMap,以便我的listview將按照2013年,2012年...之後的順序顯示2014年的事件。
這可能嗎?
謝謝。
請繼續閱讀:[http://stackoverflow.com/questions/10456847/sorting-a-arraylisthashmapstring-string-by-a-date-range?rq=1](http://stackoverflow.com/ questions/10456847/sorting-a-arraylisthashmapstring-by-a-date-range?rq = 1) –
你不能像這樣使用HashMap。特別是,使用可變對象(Map)作爲Map的關鍵字將會是災難性的。 –