-1

I am trying to implement swipeable tabs in action bar. But my problem is that I have a Activity class which displays listview. On click on another tab, it should take me to another listview. But I saw many posts with Fragments only. How could I modify my code to make it work with Activity class or what changes should I do?

Should I add ViewPager in a seperate XML file or in same XML as the listview? I tried adding ViewPager in the same XML also but I got a class cast exception.Any help will be greatly appreciated.

Siju
  • 2,585
  • 4
  • 29
  • 53

1 Answers1

0

ViewPager is used with Fragments. The ViewPager should be in the main Activity's layout file. The ListView should be in the fragment's layout file. When users swipes the ViewPager, it will change fragments.

ashishduh
  • 6,629
  • 3
  • 30
  • 35
  • So can you please tell me how should I now modify my Activity class which has listview to make it as fragment? – Siju May 23 '14 at 15:05
  • 1
    There are many tutorials for converting Activities to Fragments, just google them. Here is an example http://stackoverflow.com/a/21206098/1199931 – ashishduh May 23 '14 at 15:10