title: Update postdelay seconds for runnable when page scrolled in viewpager android?
body: <p>i am displaying images using viewpager and that images will be automatically change after 20 seconds automatically changes images every 20 seconds work perfectly but i want to reset handler postdelayed time if user manually scroll pager and next image should be display 20 seconds </p>
  
  <p>Current Working : 
  if i am on the first position of viewpager for display image this image time is 20 seconds
  after 10 seconds if i scrollpage than next image is display is only 10 seconds but it should be display 20000 seconds </p>
  
  <p>how to update post delayed time for next image display 
  check below code what i have tried.</p>
  
  <p>onpageselected i have set again post delayed but it was not worked</p>
  
  <p>Thanks</p>
  
  <pre><code>final int []sliderImageArray={R.drawable.a,R.drawable.b,R.drawable.c,R.drawable.d,R.drawable.e};
  
      runnable = new Runnable()
      {
  
          //int i=0;
          public void run()
          {   // slider image run
  
                  if(startt)
                  {   
  
  
                      if(i==0)
                      {   
                       viewPager.setCurrentItem(i,false);
                      } 
                      else
                      {
                          viewPager.setCurrentItem(i,false);
                      }
                      i++;
                      if(i&gt;sliderImageArray.length-1)
                      {
                          i=0;    
                      }
  
                  }
                  else
                  {
  
                  }
  
              imagehandler.postDelayed(this, 20000); 
          }
  
      };
      imagehandler.postDelayed(runnable,20000);
  </code></pre>
  
  <blockquote>
    <p>.</p>
  </blockquote>
  
  <pre><code>viewPager.setOnPageChangeListener(new OnPageChangeListener() {
  
              @Override
              public void onPageSelected(int arg0) {
  
  
                  i=arg0;
                  imagehandler.postDelayed(runnable, 20000);
                  Log.d("onpageselected","-----&gt;"+arg0);
  
              }
  
              @Override
              public void onPageScrolled(int arg0, float arg1, int arg2) {
  
              }
  
              @Override
              public void onPageScrollStateChanged(int arg0) {
  
  
              }
          });
  </code></pre>