J
J
Julia2013-11-14 17:06:33
Android
Julia, 2013-11-14 17:06:33

GridView and ViewPager?

Hello dear hackers.
I have a GridView, in which you can, of course, poke on list items and open a new activity: for example, preview pictures in the GridView, poke, we get a new activity with a picture in its entire size. But we can still slide the pictures to go to the next or previous one.
There is an idea that you can implement this using ViewPager, but I'm a little confused with adapters. They are also needed for GridView and ViewPager, and so the confusion begins at the moment of using the GridView adapter, we move on to the activity, which we say what to show depending on the selected GridView item. But for the ViewPager, we have to use the same activity, right?..
In general, some kind of mess in the head. Perhaps, someone’s phrase will even be enough for me, which will sort through what needs to be implemented for what and how to connect with each other without examples.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vasart, 2013-11-16
@vasart

Head-on solution: on the same activity GridView and ViewPager. When one is VISIBLE, the second is GONE, and vice versa. Each has its own adapter, but the data source is the same. By clicking on the GridView element of the ViewPager, we call setCurrentItem and give the index of the selected element as a parameter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question