Reputation: 31
I have a listview in my mainActivity and I have a detailActivity to display listview items.
I want to swipe those items using ViewPager inside my detailActivity.
mylistview is populated using a json feed.
Upvotes: 0
Views: 1072
Reputation: 287
Are you trying to open new tabs when each ListView item is clicked? If so then you should in your onItemClick() method for the list view set the viewPager to the position of the desired fragment:
mPager.setCurrentItem(positionOfDesiredFragment);
Otherwise could you please explain your goal in more detail.
Upvotes: 0
Reputation: 628
To implement the detailActivity , you need to supply a PageAdapter to the view pager.
Extend the FragmentPagerAdapter or FragmentStatePagerAdapter depending on the need and set it to the ViewPager.
Pass the same json feed as to the listview in the main activity to the above adapter and implement it.
I hope this helps.
Upvotes: 1
Reputation: 9103
There is many tutorials and examples on the web. Just have a look at Android Developers page for example.
If you are using Android Studio you can press right button on the package and create new Activity from template. Pick Tabbed Activity, it will contain layout with ViewPager and basic implementation.
Upvotes: 0