我试图在寻呼机中实现周视图,因为我正在将日期传递给函数
public static String[] getpreviousweekDate(Calendar calendar, int pos) {
// TODO Auto-generated method stub
Log.e("Position index", pos+" "+calendar);
Calendar c = calendar;
// Set the calendar to monday of the current week
c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
c.add(Calendar.DATE, pos * 7);
// Print dates of the current week starting on Monday
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
String[] days = new String[7];
for (int i = 0; i < 7; i++)
{
days[i] = df.format(c.getTime());
c.add(Calendar.DAY_OF_MONTH, 1);
}
return days;
}
我们通过
调用函数 indexTime = Calendar.getInstance();
indexTime.set(year1, month1-1, day1);
positionIndex = -1;
// Getting the current week details
Weekdays = Utilities.getpreviousweekDate(indexTime,positionIndex);
关于swipping我正在调用函数
@Override
protected void next() {
// TODO Auto-generated method stub
positionIndex = positionIndex+1;
Weekdays = Utilities.getpreviousweekDate(indexTime,positionIndex);
Log.e("The date", Weekdays[0]);
}
问题是一周是按顺序跳过..就像在第一次刷卡我得到正确的一周,第二次一周跳过我得到第三个如此...但位置索引是正确的.. 请有人帮我搞清楚