Swati Rawat
Swati Rawat

Reputation: 1729

ViewPager and Listview

I am making an android app where I have listview being populated using fedor's Lazy Loading solution. This happens after I do some work in an async task and on completion of which my listview gets populated. The listview contains an ImageView and a TextView for every single row. I want to use the ViewPager implementation where on one page, I have the listview and on selection of an item in the listview, the user gets shifted to another page on the right (or maybe he can swipe to another page) where he can get the detail screen of the ListView Item. How is this possible. Do i need to use ViewPager or some implemenation of Tabs. Also if someone can refer me to some good tutorial related to ViewPager and How to implement Activities inside viewpager, that would be great! Thanks in advance!

Upvotes: 1

Views: 2946

Answers (4)

Daniel De León
Daniel De León

Reputation: 13639

Just:

  • Set a background that support the selected state in your list item layout, like:

android:background="?android:attr/activatedBackgroundIndicator"

  • getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);

FYI: http://cyrilmottier.com/2011/08/08/listview-tips-tricks-3-create-fancy-listviews/ and http://android-developers.blogspot.mx/2008/12/touch-mode.html

Upvotes: 0

user1755441
user1755441

Reputation:

If you looking for the swipe than you should use GestureListener interface...

you can find this at following link

Upvotes: 1

SKK
SKK

Reputation: 5271

  • Use Fragments within View Pager(not activities)
  • Use ViewPager if it is a listView and some other screen for the swipe.
  • for detail view on selection of list item, use a separate fragment and load it in the container.

Upvotes: 0

pvn
pvn

Reputation: 2106

I had recently done the swiping of ListViews using viewPager it works very well

Follow this tutorial

http://mobile.tutsplus.com/tutorials/android/android-user-interface-design-horizontal-view-paging/

You can read this from android developer site also for better understanding http://developer.android.com/training/animation/screen-slide.html

Please feel free to ask any doubts I had done this recently

Upvotes: 0

Related Questions