1

I want to load array of Images one by one from drawable. At a given time the ImageView should display one image when user slides, it should load the next Image.

Can I acheive this?? I don't like gallery view, I directly need to load the single image dat fills the screen and slides through till the end of Array.

Thanks in advance for your time.

4 Answers 4

3

Take a look onto ImageSwitcher. It should fit your needs.

Sign up to request clarification or add additional context in comments.

Comments

2

I have a different solution:

https://github.com/ysamlan/horizontalpager

It's a ViewGroup where you can add children, when swiping left or right, you will show the next or previous child in fullscreen. It's also written so that it's possible to implement vertical scrolling in case you need this.

1 Comment

It acts like the android homescreen, so it snaps to it's position and all that stuff..
2

You can use ViewFilpper or ViewSwitcher or ImageSwitcher for your purposes. All these classes extend ViewAnimator, so they have very similar behavior and functionality, and only add a few useful function on top of what ViewAnimator has.

Demo: http://www.youtube.com/watch?v=mGwG8-chUEM

Comments

0

After thinking for hours I came up with solution as none of the answers helped me.

  1. Load the Imageview
  2. onclick will change the imageview image with an Animation .

Java Code

public class ImagePreviewActivity extends Activity implements OnClickListener {

        public int currentimageindex=0;
        private int[] IMAGE_IDS ={R.drawable.splash1, R.drawable.splash2, R.drawable.image_preview, R.drawable.report_incident_exclamation_mark};


        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            setContentView(R.layout.media_preview);
            ImageView imageview = (ImageView)findViewById(R.id.ImageViewPreview);
            imageview.setImageResource(R.drawable.splash1); 
            currentimageindex++;
            imageview.setOnClickListener(this);


        }


        @Override
        public void onClick(View v) {
            Animation inFromRight = 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);
                inFromRight.setDuration(500);
                    ImageView imageview = (ImageView)findViewById(R.id.ImageViewPreview);
                    imageview.startAnimation(inFromRight);

                if ((IMAGE_IDS.length)> currentimageindex){

                    imageview.setImageResource(IMAGE_IDS[currentimageindex]);

                    currentimageindex++;

                }


        }

    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.