0

So I have created an ImageSwitcher and the goal is that when you swipe left or right, the next Image in an array is loaded. Then, if you click on the ImageSwitcher it is going to start a new Activity using the image that is currently displayed.

The problem that I am having is that I cannot get the ImageSwitcher to recognize a click event. I have successfully set the swipeRight and swipeLeft gestures, and I attempt to set the onClickListener but when I click on the ImageSwitcher, nothing happens.

Any help would be greatly appreciated.

imgSwitcher = (ImageSwitcher) findViewById(R.id.highlights_image_switcher);

imgSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
    @Override
    public View makeView() {
        ImageView myView = new ImageView(getApplicationContext());
            myView.setScaleType(ImageView.ScaleType.FIT_CENTER);
            myView.setLayoutParams(new ImageSwitcher.LayoutParams(
                ImageSwitcher.LayoutParams.MATCH_PARENT,
                ImageSwitcher.LayoutParams.MATCH_PARENT));
            return myView;
     }
});

imgSwitcher.setOnTouchListener(new OnSwipeTouchListener(getBaseContext()) {
    @Override
    public void onSwipeLeft() {
        highlightsNext();
    }

    @Override
    public void onSwipeRight() {
        highlightsPrevious();
    }
});

imgSwitcher.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
       highlightsAdvance(highlightIndex);
    }
});

1 Answers1

0

So for anyone who is wondering I found the answer to my question. Since I am already implementing an onSwipeTouchListener, I cannot also implement an onClick listener because they both listen for the Down event first. So all down events are going into the onSwipeTouchListener and for that reason the onClickListener is never picking anything up. On another note, I was able to write some code to resolve this issue, if anyone is interested in seeing it, just post a comment on this and I can put it up.