Android日历添加日 [英] Android Calendar add day

查看:52
本文介绍了Android日历添加日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数组String,该数组由从数据库中获取的数据填充. 现在,对于数组的每一行,我想向日历添加一天,今天的行"0",明天的行"1",明天的行"2",等等. 我创建了这段代码来控制数组中每个元素的位置,但是如何添加天数呢? 谢谢

I have an array String populated by data taken from the database. Now for each row of the array I want to add a day to the calendar, the line "0" day today, the line "1" tomorrow, the line "2" after tomorrow etc .. I created this code that controls the position of each element of the array, but how I add the days? thanks

Calendar prova = Calendar.getInstance();
        int size = id_op.length;
        for(int i = 0; i< size; i++){                 

        }

推荐答案

您可以以毫秒为单位获取时间,然后在其中添加一天的时间.

You can just get the time in milliseconds and then add a day worth of milliseconds to it.

Calendar prova = Calendar.getInstance();
        int size = id_op.length;
        for(int i = 0; i< size; i++){                 
            Long time = prova.getTimeInMillis();
            time = time + 86400000;
            prova.setTimeInMillis(time);           
        }

这篇关于Android日历添加日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆