我从ArrayList获取多个值并将它们保存在变量中:
对于每个代码:
static ArrayList<HashMap<String, String>> test = new ArrayList<HashMap<String, String>>();
for (RoomHandler roomHandler : roomHandlerArrayList) {
HashMap<String, String> item = new HashMap<String, String>();
item.put(ROOM_ID, Integer.toString(roomHandler.getRoomID()));
item.put(ROOM_NAME, roomHandler.getRoomName());
test.add(item);
}
我在我的适配器上调用这些变量。但是当我尝试打印两个变量时,我只获取ROOM_NAME变量,当我打印ROOM_ID时,我得到ROOM_NAME值,这意味着最后一个值被记录两次。
适配器代码:
String getRoomName = (String) ((Map) getItem(position))
.get(RoomsActivity.ROOM_NAME);
String getRoomID = (String) ((Map) getItem(position))
.get(RoomsActivity.ROOM_ID);
roomName.setText(getRoomName + getRoomID); //prints ROOM_NAME + ROOM_NAME
我做错了什么?