0

I create a app with a database.in one activity with swipe to left and right the textView go to previous and next row of table. the problem it is that i want to do transition or animate in left and right swipe for next and previous row. some part of my activity code:

@Override
    public boolean onTouchEvent(MotionEvent event) {
        if (gestureDetector.onTouchEvent(event)) {
            return true;
        }
        return super.onTouchEvent(event);
    }

    private void onLeftSwipe() {
        movePrev();

    }

    private void onRightSwipe() {
        moveNext();

    }

    // Private class for gestures
    private class SwipeGestureDetector
            extends GestureDetector.SimpleOnGestureListener {
        // Swipe properties, you can change it to make the swipe
        // longer or shorter and speed
        private static final int SWIPE_MIN_DISTANCE = 120;
        private static final int SWIPE_MAX_OFF_PATH = 200;
        private static final int SWIPE_THRESHOLD_VELOCITY = 200;

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2,
                               float velocityX, float velocityY) {
            try {
                float diffAbs = Math.abs(e1.getY() - e2.getY());
                float diff = e1.getX() - e2.getX();

                if (diffAbs > SWIPE_MAX_OFF_PATH)
                    return false;

                // Left swipe
                if (diff > SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                    nokteb1list.this.onLeftSwipe();

                    // Right swipe
                } else if (-diff > SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                    nokteb1list.this.onRightSwipe();
                }
            } catch (Exception e) {
                Log.e("YourActivity", "Error on gestures");
            }
            return false;
        }
    }




    protected void openDatabase() {
        db = openOrCreateDatabase("Listo.db", Context.MODE_PRIVATE, null);
    }

    protected void showRecords() {
        String name = c.getString(1);
        noktehtext.setText(name);
    }

    protected void moveNext() {
        if (!c.isLast())
            c.moveToNext();

        showRecords();
    }

    protected void movePrev() {
        if (!c.isFirst())
            c.moveToPrevious();

        showRecords();

    }
ali.b
  • 43
  • 8
  • can´t see any part of animation...please provide more code and explain exactly what is not working... – Opiatefuchs Nov 23 '16 at 05:23
  • @Opiatefuchs i dont know about animation and then i cant use it.i want to you edit my code or tell me what i use animation. – ali.b Nov 23 '16 at 05:29
  • ok, you should google some keywords in google like animation example android. You will find much simple examples here. Believe me, google is your best teacher if you want to learn programming. Simple example for an animation on slide: http://android-er.blogspot.de/2014/12/swipe-to-slide-animated-activity.html – Opiatefuchs Nov 23 '16 at 19:12

0 Answers0