2013-11-01 94 views
0

我有一個簡單Question.Why最後一個項目名單顯示在列表的最後一個項目列表顯示在ArrayList中

任何回答感謝...

List<HashMap<String, Object>> noteItem=new ArrayList<HashMap<String,Object>>(); 

    HashMap<String,Object> hashmapNoteItem = new HashMap<String, Object>(); 

    hashmapNoteItem.put("todo_check", false); 
    hashmapNoteItem.put("todo_content", "added 0"); 

    noteItem.add(hashmapNoteItem); 

    HashMap<String,Object> hashmapNoteItem1 = new HashMap<String, Object>(); 
    hashmapNoteItem.put("todo_check", true); 
    hashmapNoteItem.put("todo_content", "added 1"); 

    noteItem.add(hashmapNoteItem1); 
+1

目前還不清楚是什麼你在這裏 – krishan711

回答

1

在您使用的不是hashmapNoteItem1 hashmapNoteItem第二代碼塊:

List<HashMap<String, Object>> noteItem=new ArrayList<HashMap<String,Object>>(); 

HashMap<String,Object> hashmapNoteItem = new HashMap<String, Object>(); 

hashmapNoteItem.put("todo_check", false); 
hashmapNoteItem.put("todo_content", "added 0"); 

noteItem.add(hashmapNoteItem); 

HashMap<String,Object> hashmapNoteItem1 = new HashMap<String, Object>(); 
// changed hashmapNoteItem to hashmapNoteItem1 
hashmapNoteItem1.put("todo_check", true); 
hashmapNoteItem1.put("todo_content", "added 1"); 

noteItem.add(hashmapNoteItem1); 
+0

問@Bismark ......好點了THKS – nitesh

0

如果你的問題是: 「爲什麼是這個名單顯示在列表的最後一個項目」中加入這一行
noteItem.add(hashmapNoteItem1);
後:
yourAdapter.notifyDataSetChanged();