title: viewpager not detecting onclicklistener
body: <p>I am using a viewpager as image slider.</p>
  
  <p>My issue is that onclicklistener is not detecting when the user clicks on the image on each page.</p>
  
  <p>This is my adapter:</p>
  
  <pre><code>public class SlidingImage_Adapter extends PagerAdapter {
  
  
      private String[] urls;
      private LayoutInflater inflater;
      private Context context;
  
  
      public SlidingImage_Adapter(Context context, String[] urls) {
          this.context = context;
          this.urls = urls;
          inflater = LayoutInflater.from(context);
      }
  
      @Override
      public void destroyItem(ViewGroup container, int position, Object object) {
          container.removeView((View) object);
      }
  
      @Override
      public int getCount() {
          return urls.length;
      }
  
  
  
      @Override
      public Object instantiateItem(ViewGroup view, final int position) {
          final View imageLayout = inflater.inflate(R.layout.slidingimages_layout, view, false);
  
          assert imageLayout != null;
          final ImageView imageView = (ImageView) imageLayout
                  .findViewById(R.id.image);
  
          imageLayout.setOnClickListener(new View.OnClickListener(){
              public void onClick(View v){
                  //this will log the page number that was click
  
                  Log.d("position","position "+position);//not working
              }
          });
  
  
          Glide.with(context)
                  .load(urls[position])
                  .into(imageView);
  
          view.addView(imageLayout, 0);
  
          return imageLayout;
      }
  
      @Override
      public boolean isViewFromObject(View view, Object object) {
          return view.equals(object);
      }
  
      @Override
      public void restoreState(Parcelable state, ClassLoader loader) {
      }
  
      @Override
      public Parcelable saveState() {
          return null;
      }
  
  
  }
  </code></pre>
  
  <p>EDIT
  Code for the viewPager in recyclerView adapter</p>
  
  <pre><code>   holder.mPager.setAdapter(new SlidingImage_Adapter(context,urls));
  
  
          holder.indicator.setViewPager(holder.mPager);
  
  
  
  //Set circle indicator radius
  
  
          NUM_PAGES = urls.length;
  
          // Auto start of viewpager
          final Handler handler = new Handler();
          final Runnable Update = new Runnable() {
              public void run() {
                  if (currentPage == urls.length) {
                      currentPage = 0;
                  }
                  holder.mPager.setCurrentItem(currentPage++, true);
              }
          };
          Timer swipeTimer = new Timer();
          swipeTimer.schedule(new TimerTask() {
              @Override
              public void run() {
                  handler.post(Update);
              }
          }, 3000, 3000);
  
          // Pager listener over indicator
          holder.indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
  
              @Override
              public void onPageSelected(int position) {
                  currentPage = position;
  
  
              }
  
              @Override
              public void onPageScrolled(int pos, float arg1, int arg2) {
  
              }
  
              @Override
              public void onPageScrollStateChanged(int pos) {
  
              }
          });
  </code></pre>