For Loop在onPostExecute中无法正常工作

Sop*_*hie 2 android for-loop

我在做错的地方,使用下面的代码create event进入Calendar(使用JSONParsing 从服务器获取日期)

 for (int i = 0; i < appointmentsArrayList.size(); i++) {

        try {
            Log.d("check", appointmentsArrayList.get(i).getDate());
            eventDate = new SimpleDateFormat("dd MMM yyyy").parse(appointmentsArrayList.get(i).getDate());
        } catch (java.text.ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
Run Code Online (Sandbox Code Playgroud)

小智 5

调用addToCalender(); 在你的for循环中

for (int i = 0; i < appointmentsArrayList.size(); i++) {

    try {
        Log.d("check", appointmentsArrayList.get(i).getDate());
        eventDate = new SimpleDateFormat("dd MMM yyyy").parse(appointmentsArrayList.get(i).getDate());
        addToCalender();
    } catch (java.text.ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
Run Code Online (Sandbox Code Playgroud)