2015-02-23 81 views
0

我試圖通過一個hashmap在listview中顯示一些String []值。當我去嘗試顯示這個,自己的arent顯示的值,但顯示的數字的隨機顯示[Ljava.lang.String; @ .....「]我的相關代碼如下:HashMap顯示字符串[]在ListView中

//NEW TEST STUFF 
    feedList= new ArrayList<HashMap<String, String[]>>(); 
    map = new HashMap<String, String[]>(); 

//TEST ARRAYS 
    a = new String[] {"a","b"}; 
    b = new String[] {"c", "d"}; 

//NEW STUFF 
    simpleAdapter = new SimpleAdapter(this, feedList, R.layout.list_view, new String[]{"one", "two"}, new int[]{R.id.companyListViewColumn, R.id.colorListViewColumn}); 


map.put("one", a); 
map.put("two", b); 
feedList.add(map); 

crossReferenceListView.setAdapter(simpleAdapter); 

是什麼原因造成這種???

+0

嘗試更改訂單。先寫map.put(),然後再寫simpleAdapter = new .... – Apurva 2015-02-23 03:49:08

回答

0

問題是,你插入串更多的密鑰,這樣的Hashmap通常是指新的分配密鑰。哈希映射不允許您將關鍵數據類型存儲到String []。使用HashTable for st或者多個鍵和值。