I have implemented an application with image view in my application i would like to implement when user move the image right side then i would like to get the next acitvity.
How can i write an event or any other code for move the image just right side?
I have used am imageView code as:
(ImageView)findViewById(R.id.slide) //event for move right here
Intent it = new Intent(Slide.this,NextActivity.class);
startActivity(it);
Please any body help me…
So, if i understood you correctly, you want to move an ImageView across the screen, drag it, and when you hit a certain spot with it you want to start another activity?
If so, you could try and use the code below…which let’s you drag your imageview across the screen
Just add an onTouchListener to the imageView you’re trying to slide (move/drag)
Then add this code to handle the Touch events
The above should drag your imageview accross the screen.
You can also implement in the MotionEvent.ACTION_MOVE event …. to limit the movement of the ImageView accross the screen. So check the new coordinates of your finger across the screen and check if they are out of bounds. If so, then do nothing. If they aren’t out of bounds, then change the left and upper margins of the ImaveView.
Also, on the MotionEvent.ACTION_UP event, check to see if the left margin of the ImaveView is over a predefined limit (which means the user slided the imageView over you intended position). If so, you can continue doing whatever you want, which means starting an activity. OR, if you don’t want to open the activity while the user is dragging, not only after he has removed his finger from the imageView, then just do that if () i’ve written under the MotionEvent.ACTION_MOVE event. Insert there the interval you want, so when the imageView is dragged inside that interval, the activity starts.
If you’re confused, please ask 🙂 It’s very late here, and i’m tired, so i might have not explained it properly 😀