Skip to content Skip to sidebar Skip to footer

How To Get Screens By Clicking And By Last Screen Clicking It Should To Previous Activity

how to get screens by clicking and by last screen clicking it should to previous activity and following is my code.i want to modify this code as by clicking instead of scrolling.so

Solution 1:

In your onTouchEvent function, inside switch case MotionEvent.ACTION_UP, please add this after your if condition

  else {
      switchToScreen(mCurrentScreen + 1);
  }

add this function to your class

    private void switchToScreen(int whichScreen) {
       if (!mScroller.isFinished())
             mScroller.abortAnimation();
        whichScreen = Math.max(0, Math.min(whichScreen, getChildCount() - 1));
        mNextScreen = whichScreen;
        final int newX = whichScreen * getWidth();
        mScroller.setFinalX(newX);
        invalidate();
    }

Post a Comment for "How To Get Screens By Clicking And By Last Screen Clicking It Should To Previous Activity"