Here is I am using ViewPager in android.I want when a User clicke on A picture then a Intent will open.But Know when i Scroll from one activity to another The Intent is calling This is my code
What Else i Need to change in My Code that When a user Clicks on A Particulr Image then Only the Intent Will open Not in Scrolling?
I understood. To phrase it differently: Does "onPageScolled" sound to you like a callback to detect a click? Or might there be some other callback better suited for that purpose?
Use a callback that triggers only if that image is clicked. That probably means attaching the listener to the View that holds the image, not to the ViewPager.
The callbacks here are the methods defined by the OnPageChangeListener: Callback_(computer_programming). They're "called back" from code other than where they are defined. You may not have heard the term, but anyone using event-driven APIs (like GUIs, whether Android or AWT/Swing) will be familiar with the concept.
Um, I think you missed pretty much all the points I've been trying to make in all my replies. More directly: Why are you listening for events in the ViewPager if you're actually interested in events concerning the images (or whatever View they are part of, which you haven't said so far)? If you are interested in "click" or "touch" events, why are you listening for "page scroll" or "page select" events?
I'm sure you can figure it out on your own; that'll be much more useful as a learning experience for you. Look up the javadocs of the View holding the images to learn what listeners you can attach to it. Don't forget to check the superclass(es) of it as well. Which listeners are those? Which of those suggest themselves if you want to handle clicking on it?
A hint: listeners are generally attached via methods called "setOn..."
Ok here is few Changes that I made in My Code and At least it let me Understand How these method Interact with Each Otehr
By This I have seen that Each time when we switch to a New Screen Old View is Removed than Instatite Item is Called again and again.
My Question is How can I get currently focused View and Its id?