嗨,我的代码只显示了 ArrayList 的最后一个元素!这是我的代码:
ListView list = (ListView) findViewById(R.id.t1player_statsList);
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
for(Player player : team1.getPlayers())
map.put("player", player.getName());
map.put("score", "0");
mylist.add(map);
SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, R.layout.mylistrow,
new String[] {"player", "score"}, new int[] {R.id.NameCell, R.id.ScoreCell});
list.setAdapter(mSchedule);
我觉得这与我的 for 循环有关。有人可以帮忙!!提前致谢!