Swiping from one screen to another screen in android

598 views Asked by At

I have two arraylists name and price in an activity. It contains the name and prices of 3 products.We can call it as Product A, Product B, Product C. Now I want to display the product details of all 3 product that is name and price in the screen in such a way that only one product details will be displayed on the screen initially. When I swipe the screen left or right, the product details of product A should be swiped over and the product details of the next product should come on to the screen. So for example if the product details of A is displayed first, then I swipe right then product details of B should come up. then again I swipe right then product details of C should come up. When I further swipe right, since there are no more products available, the product A should come back to the screen. This is what it should happen when I swipe the screen on left side.

How can this particular thing be achieved.? Can someone give me a clue to where should I start from? Does the require a second activity to show the swiping of the details? I have searched Google and all I have found is swiping from one activity to another activity for left or right swipes. But my case is different than that. Since in my case if the number of products is a large value, I cannot create activities for that much products in my application. Also the count of total number of products is known only after running the application. So there is no way of creating that much activities during run time. So I think there would be another way for my problem. But I don't know the solution for it. And haven't found any places where my problem could be solved. So that's why I'm posting this question here. I need any thing to start. So If anyone know the answer will be surely helping me a lot. Thanks in advance and sorry for my long essay.

1

There are 1 answers

4
Tadej On

From what you're saying, I believe ViewPager would provide the functionality you require.

You probably want to display a ProgressBar until you load the data from the server, then populate and display your data in a ViewPager.