My View Pager consists of photos,audios and videos.Audio View consists of play button to play the audio.When i click on play button it disappears and audio start playing.When I stop the audio or when track is completed play button again becomes visible. If i swipe the view while audio is being played and move to next view then the audio stops.But the issue is if I move to next view by swiping while the audio is being played and then return to the audio view then i can't see the play button on View Pager.However if i swipe to next to next view or to further next views and then return to the audio view then i can see the play button on Audio View.Same happens for back also.If I move to previous view by swiping from audio view while audio is being played and then return to the audio view the i can't see the play button on View Pager.However if i swipe to previous to previous view or to further previous views and then return to the audio view then i can see the play button on View Pager..
Issue in swiping views in ViewPager
1.4k Views Asked by Android Developer At
2
There are 2 best solutions below
0
android developer
On
What you are describing is just the way the ViewPager works.
At any moment, the only pages it holds is the current one, one on the left and one on the right. When you scroll, pages can be destroyed according to where you are.
In any case, if you wish to handle switching between pages, you can simply add a listener to the ViewPager, by using setOnPageChangeListener .
This way, you can identify which page was selected before, and which one is selected now.
If you wish, you can post a project and I will see what I can do to fix it.
I also suggest to use fragments instead of views for a bit easier handling of each page's lifecycle. In addition, if you wish to save the state of the page, you can use FragmentStatePagerAdapter .
Related Questions in ANDROID
- Delay in loading Html Page(WebView) from assets folder in real android device
- MPAndroidChart method setWordWrapEnabled() not found
- Designing a 'new post' android activity
- Android :EditText inside ListView always update first item in the listview
- Android: Transferring Data via ContentIntent
- Wrong xml being inflated android
- AsyncTask Class
- Unable to receive extras in Android Intent
- Website zoomed out on Android default browser
- Square FloatingActionButton with Android Design Library
- Google Maps API Re-size
- Push toolbar content below statusbar
- Android FragmentPagerAdapter Circular listview
- Layout not shifting up when keyboard is open
- auDIO_OUTPUT_FLAG_FAST denied by client can't connect to localhost
Related Questions in ANDROID-VIEWPAGER
- Android FragmentViewPager in Fragment
- Pager with RecyclerViews containing realmObjects keeps crashing with IllegalState
- FragmentPagerAdapter: IllegalStateException Can't change container ID of fragment
- ViewPager bug if i turn on the screen again
- How to initialize a ViewPagerAdapter in a Fragment when MainActivity's OnCreate() is called?
- Fragment doesn't show properly in ViewPager
- Change background color of tabBar in v4 viewPager
- ViewPager Fragment displaying Memory Error for loading ImageViews
- Refresh on swiping tabs android
- how to handle Gridview Click in ViewPager?
- TabLayout tab selection
- ViewPager that listens to clicks
- Hide Parent Fragment from the Fragment in the viewPager
- Android ViewPager adapter - force getPageWidth every time
- Slide Changes in slideshow when a button is clicked using viewpager android
Related Questions in ADAPTER
- dynamically inflating views into listView items. odd behaviour
- How can I implement a delete button in a ListView and delete from database?
- Custom ArrayAdapter messing up views, with NullPointerException
- What's the proper way to implement a custom SimpleCursorAdapter?
- ImageView setBackgroundRessource not update even with inflate
- Sliding menu adapter(android)
- Recyclerview adapter initialised with empty array and subsequently populated with values
- RecyclerView deleting item doesn't call OnScrollListener
- How to merge StickyListHeadersListView and Cursor
- Attach a method to a module
- Recyclerview - smoothScrollToPosition to Top of list and then animate the addition of item
- GridView doesn't work
- Issue in sending value from MainActivity to Custom Adapter
- Set Json Array values to AutoCompleteTextView in Android
- Holder returning wrong values
Related Questions in ANDROID-VIEW
- Two views with same elevation side-by-side
- Clone Views in Android
- Android 5.0 does not respect view's margins
- Unable to instantiate activity ComponentInfo starting my app
- Reset all Views in fragment
- Decapitalizing text in Android view
- Replacing fragments quickly causes a weird screenshot of the previous fragment to persist and brought forward
- When I try to run an AsyncTask on a button click, I receive a fatal error "Could not find a method createView(View) in MainActivity"
- Can Activity classes be made launchable only during development/debug?
- Get ViewPager height and width in pixels only once inside Fragment
- how do i check if the edit text view contains 2 white spaces?
- How to get a list of all views in a fragment?
- Data does not display properly in Adapter when Removing/Adding
- How to wrap background color for some widgets?
- how to update a customview according to the data change?
Related Questions in VISUALIZER
- Audio Visualizer with Canvas
- R.Raw.Test Can't resolve
- Issue in swiping views in ViewPager
- Jmeter - Spline Visualizer
- Visualizer onFftDataCapture - Does the byte[] index represent frequency?
- android: Visualization of sound from Spotify
- I can't see visualizer while recording voice on Android
- Android Visualizer Detect Beat? And Visualizer.setCaptureSize() not Working? Alternatives?
- How to visualize simulations in drake - a generic example
- Can do merge sort but having problem animating the merge sort visualizer in react
- Update in View control doesn't effects the final view in open3d
- Following tutorial on audio visualisers in javascript using audio context, audio works but visualiser isn't
- Android Visualizer FFT / waveform affected by device volume?
- Is it possible to import a project in Kony visualizer enterprise edition which was created in Kony quantum?
- How to avoid "HTMLMediaElement already connected previously to a different MediaElementSourceNode" in the AudioContext Interface?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The reason is that when the fragment 0 is active, then Android also initiates the adjacent fragments, in this case only 1. When you swipe to fragment 1, since fragment 0 is already initiated, android only initiates fragment 2. This is the reason when you move back from fragment 1 to fragment 0, you do not see the play button.
Now when you move to fragment 2 and then back to fragment 1, fragment 0 will get refreshed, hence you can see the button again.
Honestly, I have struggled with the same problem. This has been discussed in StackOverflow multiple times. I found the following post to be most useful.
Update data in ListFragment as part of ViewPager