-1
に取り組んでいないカレンダーに日追加:私はここで週の日の配列とそれらの日付を作成してい私は次のコードを持っているのAndroid
public void createWeeks(JSONArray TargetDays){
int helper, targetDayPos, curDayPos;
JSONArray dateContainer = new JSONArray();
JSONArray dateData = new JSONArray();
Calendar c = Calendar.getInstance();
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
Utilities dayConverter = new Utilities(getApplicationContext());
for(int i=0 ; i<TargetDays.length() ; i++){
try {
targetDayPos = dayConverter.getDayPosition(TargetDays.getString(i));
curDayPos = dayConverter.getCalenderDayPosition(dayOfWeek);
if (curDayPos > targetDayPos) {
helper = curDayPos - targetDayPos;
c.add(Calendar.DATE, -helper);
}
else if(targetDayPos > curDayPos){
helper = targetDayPos - curDayPos;
c.add(Calendar.DATE, helper);
}
dateData.put(c.get(Calendar.YEAR));
dateData.put(c.get(Calendar.MONTH)+1);
dateData.put(c.get(Calendar.DAY_OF_MONTH)+1);
Toast.makeText(getApplicationContext(),curDayPos+"\n"+targetDayPos,Toast.LENGTH_LONG).show();
dateContainer.put(dateData);
} catch (JSONException e) {
e.printStackTrace();
}
}
try {
weekDayList.put("days",TargetDays);
weekDayList.put("dates", dateContainer);
} catch (JSONException e) {
e.printStackTrace();
}
}
を。日を追加することはできませんし、最後には今日の日付を取得しています。
は、あなたが([、最小完全、かつ検証例]を作るでしhttp://stackoverflow.com/help/マック)私はそれが大いに役立つと確信しています(私たちとあなた)。 –
私はカレンダーの "追加"方法について助けが必要です。それは何もしていない。何も起こりません。私はそれと一緒に日を追加した後、私はそれがまだ追加する前に同じ日付だ時間を得る。 @Ole V.V. –
私は 'Calendar.add()'にかなりの自信を持っています。私はあなたの問題がどこか別のものだと思っています。デバッガを試しましたか? –