Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8956843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:51:38+00:00 2026-06-15T14:51:38+00:00

I am storing two images in an array, the images come up but what

  • 0

I am storing two images in an array, the images come up but what I am trying to achieve is when the user swipes the screen to the right the second image comes up and when swiped left back to the first image. I am quite new to android app development some help would be much appreciated. At the moment all that happens is when the user clicks the image it goes to the second image and thats it.

I have also added my code:

public class ScrollingQuran extends Activity {

private ImageView imgView;


private Integer[] Imgid = {

        R.drawable.page1, R.drawable.page2

};



@Override

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.qurangallery);


    imgView = (ImageView)findViewById(R.id.ImageView01);

    imgView.setImageResource(Imgid[0]);

    imgView.setOnTouchListener(new OnTouchListener()
    {

        public boolean onTouch(View v, MotionEvent event)
        {
        ImageView iv = (ImageView) v;
        if (event.getAction() == MotionEvent.AXIS_VSCROLL) {

            iv.setImageResource(R.drawable.page2);
            return true;
        } else if (event.getAction() == MotionEvent.AXIS_HSCROLL) {
            iv.setImageResource(R.drawable.page2);
            return true;
        }

        return false;
    }

});

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:51:39+00:00Added an answer on June 15, 2026 at 2:51 pm

    I think this code will help you.In this transimg1 is an imageswitcher

    in_right = AnimationFactory.inFromRight();  
    in_left = AnimationUtils.loadAnimation(this,android.R.anim.slide_in_left);  
    out_right = AnimationUtils.loadAnimation(this,android.R.anim.slide_out_right);      
    out_left = AnimationFactory.outToLeft();
    gestureDetector1 = new GestureDetector(new MyGestureDetector1());
    gestureListener1 = new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
                return gestureDetector1.onTouchEvent(event);  
        }
    };
    
    transimg1.setOnTouchListener(gestureListener1);
    class MyImageSwitcherFactory implements ViewFactory 
    {
        public View makeView() 
        {
    
           ImageView imageView = new ImageView(getApplicationContext());
           imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
           imageView.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
           return imageView;
    
        }
    }
    
    public static class AnimationFactory 
    {
           public static Animation inFromRight() 
            {
               Animation inFromLeft = new TranslateAnimation
               (
                       Animation.RELATIVE_TO_PARENT,1.0f,Animation.RELATIVE_TO_PARENT,0.0f,
                       Animation.RELATIVE_TO_PARENT,0.0f,Animation.RELATIVE_TO_PARENT,0.0f
               );
               inFromLeft.setDuration(250);
               inFromLeft.setInterpolator(new AccelerateInterpolator());
               return inFromLeft;
           }
           public static Animation outToLeft() 
           {
               Animation inFromLeft = new TranslateAnimation
               (
                  Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  -1.0f,
                  Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
               );
               inFromLeft.setDuration(250);
               inFromLeft.setInterpolator(new AccelerateInterpolator());
               return inFromLeft;
           }
    }class MyGestureDetector1 extends SimpleOnGestureListener {
        @Override
          public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) 
          {
              try 
              {
    
                    if((e1.getX()-e2.getX()>SWIPE_MIN_DISTANCE)) 
                    {
                        gif.setVisibility(View.INVISIBLE);
                    }
                    else if(e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE)
                    {
                        gif.setVisibility(View.VISIBLE);
                        gif.start();
                    }
              }
              catch(Exception e)
              {
                  Toast.makeText(getApplicationContext(), e.toString() + " MyGestureDetector2 count=" + exccount , Toast.LENGTH_SHORT).show();
              }
              return false;
          }
    
        @Override
        public boolean onDown(MotionEvent arg0)
        {
            return true;
        }
    }
    

    Here is a blog from Dustin Graham with more examples: http://developingandroid.blogspot.in/2009/09/implementing-swipe-gesture.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've two routes, 1) creating sub-tables for each user and storing his individual content
In my app, I'm storing Bitmap data in a two-dimensional integer array ( int[,]
am storing two arrays in one column.first one is images stored as image1* image2
So I'm trying to keep two copies of a set of images cached in
I have two models in my Django application, for the purposes of storing search
In Zend Framework in Response Class there are two different arrays for storing headers:
I was thinking that I would have two tables for mysql. One for storing
I am trying to create a md5 string from the byte array of an
From my controller I am passing two instance variables @events = Event.all and @images
hiii...i am able to show image from images urls, actually images urls was stored

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.