2011-08-07 42 views
0

的中间现在,我使用这个代码将项目添加到ListView:添加项目的ListView

SimpleAdapter adapter; 
List<HashMap<String, String>> painItems = new ArrayList<HashMap<String, String>>(); 
ListView listthings; 
int[] to; 
String[] from; 

private void addItem() { 
    HashMap<String, String> map = new HashMap<String, String>(); 
    //put stuff in the map here. 
    painItems.add(map); 
    adapter.notifyDataSetChanged(); 

} 

我在想,如果我能到一个项目在一定添加到列表而不是列表的末尾。这似乎是不应该太难的事情,但我可能会错过一些根本性的东西。

感谢您的帮助和欢呼。

回答

1

是只使用附加的重载版本:

myList.add(myPosition, myItem) 
+0

感谢您的答案,我喜欢你是特定于android本身。非常简洁! – Kgrover