Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在viewpager上获取与一天对应的一周_Android - Fatal编程技术网

Android 在viewpager上获取与一天对应的一周

Android 在viewpager上获取与一天对应的一周,android,Android,我试图在寻呼机中实现weekview,因为我将日期传递给一个 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

我试图在寻呼机中实现weekview,因为我将日期传递给一个

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;
 }
切换时,我正在调用函数

@Override
protected void next() {
    // TODO Auto-generated method stub
    positionIndex = positionIndex+1;
    Weekdays = Utilities.getpreviousweekDate(indexTime,positionIndex);
    Log.e("The date", Weekdays[0]);     
}
问题是,本周将按固定顺序跳过。。就像第一次刷卡一样,我得到了正确的一周,第二次跳过了一周,我得到了第三次,以此类推。。但是位置指数是正确的。。
请有人帮我弄清楚

你什么时候调用next()函数的?在哪种方法中?当滑动事件检测到时,您是否滑动查看寻呼机?如果是这样,请从viewPager.setOnPageChangeListener()方法获取位置,然后尝试继续该位置。但我不确定这是否是必需的。位置I是否正确。。我实际上是在接受那个位置,您的意思是从viewPager.setOnPageChangeListener()方法中获取位置吗?如果是,那么需要再次添加+1吗?
@Override
protected void next() {
    // TODO Auto-generated method stub
    positionIndex = positionIndex+1;
    Weekdays = Utilities.getpreviousweekDate(indexTime,positionIndex);
    Log.e("The date", Weekdays[0]);     
}