For Loop在onPostExecute中无法正常工作

时间:2015-07-31 12:05:51

标签: android for-loop

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

 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();
        }

    }

1 个答案:

答案 0 :(得分: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();
    }

}