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 answers
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
- Creating global Class holder
- Flutter + Dart: Editing name of a tab shows up a black screen
- android-pdf-viewer Received status code 401 from server: Unauthorized
- Sdk 34 WRITE_EXTERNAL_STORAGE not working
- ussd reader in Recket Native module
- Incorrect display of LinearGradientBrush in IOS
- The Binary Version Of its metadata is 1.8.0, expected Version is 1.6.0 build error
- I can't make TextInput to auto expand properly in Android
- Creating multiple instances of a class with different initializing values in Flutter
- How to create a lottie animation
- making android analyze with coverity sast tool
- Flutter plugin development android src not opening after opening example
- I initialize my ViewModel in the Activity with several fragments as tabs, but the fragments(tabs) return null for the updated livedata
- Node.js Server + Socket.IO + Android Mobile Applicatoin XHR Polling Error...?
- How I can use the shared preferences class?
Related Questions in ANDROID-VIEWPAGER
- Why does my ViewPager not show anything when i add a scrollview?
- Pdf with page cURL effect
- Android View Pager2 horizontal carousel
- Viewpager2 and ChilfFragment
- fragments when used with ViewPager2 is not geting visible(STARTED) prior I add any view to any of the Fragment
- Jetpack compose Horizontal Pager content scroll effect is not smooth
- Clickable element does not bring nested scroll to parent Bottomsheet behavior
- Spinner item selection makes mess of views
- Simple example of ViewPager2 just does not work
- Jetpack Compose Pager Views/Screens Caching
- ViewPager2 fetching data from API doesn't work properly
- Carousel Recycler View Android Kotlin
- Achieve tablayout in composable
- Why tabs are not visible in the fragment when using Tablayout with viewpager?
- ViewPager2 & Jetpack Navigation: How to get a reference to the current ViewPager2 page/fragment?
Related Questions in ADAPTER
- Type Adapter for Offset in hive flutter
- sveltekit adapter-node docker volume issue serving updated static files after build time
- Accessing images on the Fragment Design page from within Adapter
- How to get single item which is visible to user in recyclerview but not all the loaded items from recyclerview?
- How to Improve RecyclerView Adapter and Is It Good Practice? I was wondering how this could be improved
- AutoCompleteTextView not adjusting height
- ItemDecoration in nested RecycleView changes paddings after adding new item in parent RecycleView
- Optimizing RecyclerView Showing Items in Android, Java: Handling Dataset Extraction
- adapter doesnt change when list is changed in kotlin
- How to create a service with dependency to a wifi adapter in Windows
- ViewPager2 doesn't show my images how to solve it?
- StickyListHeadersAdapter defining multiple ColorDrawable objects and displaying them as the background color. When the same Color is used, it is buggy
- RecyclerView horizontal linearlayout manager is causing recyclerview not showing
- Transferring items between RecyclerView in Kotlin
- How to remove the space occupied by hidden items in a Recyclerview?
Related Questions in ANDROID-VIEW
- Android Studio pinch scaling - ScaleGestureDetector - doesn't work in a custom View
- Android - infinite ruler/slider to change int value
- Window Manager cant create view
- Make image overlap its parent view in Jetpack Compose
- Kotlin obsever not executing changes on view, after re-entering the fragment
- How does onInterceptTouchEvent work for two overlapping ViewGroup?
- Jetpack Compose WebView: Softkeyboard Enter Key behaves differently based on number of input fields
- Click a PopupMenu button with Espresso?
- How to change arcgis map for kotlin locationDisplay mode in jetpack compose?
- Android Views in Jetpack Compose
- Scrollable ComposeView in XML ConstraintLayout: scroll position jumping on state change
- Positioning an Overlaying or floating View Above another view in Layout
- Compose AndroidView is not rendered on older phones (Android 6 / 21 API, Samsung S5) after returning to alive Activity (onStart, onResume)
- How to create custom calendar in android kotlin
- AppWidgetHostView is not updating inside AndroidView composable
Related Questions in VISUALIZER
- .Kar file on IOS xcode
- How do I fix sway waybar not displaying my custom module?
- 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
- Can do merge sort but having problem animating the merge sort visualizer in react
- How to visualize simulations in drake - a generic example
- reCAPTCHA implementation on kony
- How should I adjust my bubble sort algorithm in python tkinter? (visualizer project)
- How To make speech visualizer for speech recognition without using mediaDevices.getUserMedia?
- Uncaught TypeError: Cannot read properties of undefined (reading 'style') error
- I have installed a plugin named JIVE in the Eclipse software. it prompts that the source code is not available when i use it
- Android audio visualizer: cannot make it to work with tts
- FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x<sanitized>)
- How to save an audio stream as a file and play it in php and html
- ANN Visualizer ERROR: Layer not supported for visualizing
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?
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)
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