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);
}
});