How to create App Into with images and a pager below? - android

I want to have a bunch of images that show how my app works and have a dot-type pager at the bottom, like the example below. What UI Element should I be using?
Is Android ViewPager suitable for this? how will be adding the small circles below which act like page numbers.
EDIT: After I posted this question, I found this library. Would like feedback on how to do this from scratch.

Actually, if you look thought the code at https://github.com/JakeWharton/ViewPagerIndicator you can get a nice feedback on how to do it from scratch. The lib uses a custom View , but you can emulate this kind of behavior with some existent views, for instance. Basically:
Create a LinearLayout below your ViewPager. Set the orientation to horizontal;
Put some RadioButtons in it (you can do it dynamically based on your adapter size);
In your Activity, Fragment or whatever set a PagerListener for your ViewPager;
This listener is provided by the ViewPager API and you can check and uncheck your RadioButtons according to the position in the ViewPager with the method onPageSelected(int position), for instance.
There you go, a (very) basic ViewPagerIndicator.

Related

Make a loop in PagerAdapter

I want to loop my Viewpager and Im using the PagerAdapter extension. Everything I found in the net was an example with Fragments.
I want to solve this with a normal pageradapter. So When I Swipe from 1st view to left I want to be in the last View , and when I swipe from last view to right I want to change to 1st.
How can I solve this in an easy way (maybe without any libaries) ?
You can use the viewpager's setCurrentItem() method for achieving such functionality. This method takes the position (zero-based) of the view you want to navigate to.
https://github.com/TobiasBuchholz/CircularViewPager
I used this library, but there some problems in it when you try to show many circular views simultaneously

How to create a new tab based on a text length?

I'm implementing a fragment which is based in a ViewPager for sliding slides (see here).
So, I would like to know if it's possible to get a new sliding tab dynamically, based on a text length (which is displayed in a TextView inside of ViewPager) I want to display inside that ViewPager (to get a similar book view).
Thank you.
Go back to that link you posted about ViewPager and re-read it focusing on PagerAdapter. The concept is similar to the list adapter. So for example, you create a PagerAdapter that will take your content (in a constructor, for example), and determine how the content is broken up into pages. Say you pass in some content and your PagerAdapter determines there are 17 pages. Your override for PagerAdapter.getCount() would return 17. Then in instantiateItem() (or maybe getItem(), if you're using FragmentPagerAdapter), you would create the view that is to be displayed at page position, which is a parameter.
Fair Warning! It sounds like you want to page some text horizontally like pages in a book. You should know that TextView won't be able to do things like, "well I'm this size, so I can display this much text". You will need to use things like android.text.StaticLayout to figure out stuff like that. Do-it-yourself text layout is advanced Android programming, so brace yourself.

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!
If you looking for the swipe than you should use GestureListener interface...
you can find this at following link
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
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.
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

Google Currents like Viewpager + adapter (not indicator)

I'm learning how to build an adapter like the one demonstrated in Currents.
I know the basic classes used to achieve what we see in currents : ViewPager, ViewPagerIndicator, and a custom view showing 6 ImageViews and textviews below it.
My question is, how do we go about building a custom adapter that will automatically fill in 6 items in the first viewpager page, and continue filling it on the next page automatically? I'm guessing it will be something along the idea where the number returned from getCount() will be used to determine how many viewpager "pages" are there, (in this case divide by 6 ).
I have successfully tried building a similar view using GridView + viewpager+indicator, but i'm sure Currents is not using gridview to achieve this. Since this is definitely not extending ListView nor GridView, how can i go about solving this? Thanks in advance.

Android: using viewfliper with dynamic no of slides, number of slides can vary

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
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.
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.

Categories

Resources