0
我想插入多個單個項目到一個ArrayList> 這裏是我的代碼:安卓插入多個單項成的ArrayList <HashMap的<字符串,字符串>>從的HashMap <String,字符串>
public static ArrayList<HashMap<String, String>> alarmClocks = new ArrayList<>();
public void q1() {
int[] multipleHours = {9, 11, 13, 14, 15, 17, 18}; //store here the hours for every alarm you want to set
int[] multipleMinutes = {45, 0, 0, 0, 45, 0, 45}; //store here the minutes
String[] multipleDestinations = {"Departure", "Quezon Heritage House", "Art In Island", "Quezon City Experience", "Quezon Memorial", " Destination 5", "Destination 6"}; //same thing for destinations
String[] multipleReminders = {"You need to go to Destination 1", "Timeout, Go to next destination", "Timeout, Go to next destination", "Timeout, Go to next destination", "Timeout, Go to next destination", "Timeout, Go to next destination", "Package Ended!"}; //and reminders
HashMap<String, String> alarm = new HashMap<>();
alarm.put(ApplicationConstants.HOUR, String.valueOf(multipleHours));
alarm.put(ApplicationConstants.MINUTE, String.valueOf(multipleMinutes));
alarm.put(ApplicationConstants.REMINDER, String.valueOf(multipleReminders));
alarm.put(ApplicationConstants.DESTINATION, String.valueOf(multipleDestinations));
alarmClocks.add(alarm);
}
插入應該是這樣的:
項目1:9 - 45 - 出發 - 你需要去的目的地1
項目2:11 - 0 - 奎鬆古屋 - 超時,前往下一個目的地。
我的問題是代碼包括陣列中所有項目的
錯誤提示了這樣的:
java.lang.NumberFormatException: Invalid int: "[9, 11, 13, 14, 15, 17, 18]"
我要回答它(到後期),但這個兄弟是正確的使用循環 – Salman500
我很抱歉缺乏有關問題的細節,但我需要的代碼放入onClick。 –
你想在哪個視圖上點擊? –