I am developing an application in which I am using a ViewFlipper
with a custom OnTouch
implementation. In the ViewFlipper
, I have about 2
I detect end of children by custom ViewFlipper
public class ExViewFlipper extends ViewFlipper {
private OnChangeViewListener mOnChangeViewListener;
public ExViewFlipper(Context context) {
super(context);
}
public ExViewFlipper(Context context, AttributeSet attrs) {
super(context, attrs);
}
public interface OnChangeViewListener {
/**
* call on Change view
*
* @param index next index
* @param hasNext true if next view is exist
*/
void onChange(int index, boolean hasNext);
}
public void setOnChangeViewListener(OnChangeViewListener listener) {
mOnChangeViewListener = listener;
}
@Override
public void showNext() {
super.showNext();
if (mOnChangeViewListener != null) {
mOnChangeViewListener.onChange(getDisplayedChild(), true);
}
}
@Override
public void showPrevious() {
super.showPrevious();
if (mOnChangeViewListener != null) {
mOnChangeViewListener.onChange(getDisplayedChild(), false);
}
}
public boolean isFirstItem() {
return getDisplayedChild() == 0;
}
public boolean isLastItem() {
return getDisplayedChild() == getChildCount() - 1;
}
}