1

I need to implement an application which uses a sliding view (ViewFlipper) for one of its activity, this activity displays information stored on and array and passed from the previous activity via intent. The number of slides or tabs is expected to vary depending on the number of elements in the array. i.e for 4 elements in the array,we shall get 4 slides and when there is only 3, we have the same amount of slides displaying respective information accordingly.

Any idea on how to implement this, an example if possible? I am very new to android development. please help

androNew
  • 65
  • 6
  • What types of slides are you displaying? – sdfwer Mar 22 '12 at 14:36
  • @sdfwer in fact I need to display information about different entities. Each slide is expected to holds the details of one persons for instance.By switch left to right, I shall view the details of a different person and vice versa. – androNew Mar 22 '12 at 14:44

2 Answers2

0

Create an .xml file now implement a view flipper design the layout of how each pages work. I suggest using a relative layout and add those views inside the view flipper. Seems pretty basic now go search tuts on .xml, viewflippers, types of layout, textviews, and don't put questions here next time asking for answers. We are a community after all helping people with problems who actually tries to do something not for copy and paste people.

sdfwer
  • 1,042
  • 3
  • 10
  • 23
  • When you encounter an actual problem you can post it in stackoverflow. – sdfwer Mar 22 '12 at 14:50
  • thank you but sorry, if you don't want to answer a question just skip it. I have said it, I am new to android. What i want to have is a slide which can hold 1 2 3 ,4 or x slides(details page). I did not asked for source code but for any guidance on how to implement this dynamically, preferably from someone who has tried it before saying something. Simple English will do, am asking for some guidance not for some code. but again thanks. – androNew Mar 22 '12 at 15:14
0

For this purpose it's best not to use the ViewFlipper, but instead use a ViewPager to which you can dynamically add 'subviews' (pages) using a PagerAdapter. ViewPager will provide performance benefits over ViewFlipper as it loads (and removes) pages on-demand (like a ListView).

Set-up of the ViewPager is in essence the same as setting up a ListView. You can use the ViewPager on Android <3.0 devices using the compatibility library.

Create your own class that extends PagerAdapter, and set mViewPager.setAdapter(mAdapter);. In your adapter, in the method instantiateItem() you will build your 'page' and add it to the parent with mViewPager.addView(newView);.

For a more detailed example of how to set-up a ViewPager see my answer here.

Community
  • 1
  • 1
Reinier
  • 3,836
  • 1
  • 27
  • 28