Why ViewPagerIndicator calculate all titles every time - android

I am using ViewPager and ViewPagerIndicator (here). WHen I debug, I see that the ViewPagerIndicator call getPageTitle() to get title of all pages every time I scroll the Viewpager. Now I have more then 1000 pages. So, when I scroll, the titles aren't smooth any more. Did you face this problem before? Please share with me the solution. Any recommend are welcome.
Thanks a lot.

I have the same issue, I have a ListView with an ArrayAdapter. Each time I scroll back to the page, the list keeps recreating it self and expands.. I solved it with a simple boolean to check weather the list have items or not, but that's not the optimum solution. I think there is something in OnPageChangeListener from android.support.v4.view.ViewPager package that ViewPagerIndicator doesn't address.

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

ViewPager or ViewFlipper or something else for unlimited set of data?

My source of data can me give unlimited set of data (it's like days in calendar). I have to show each item separately on screen (one item at a time). For each item I have to make query into my data source. I don't know which approach will be better ViewPager (how handle in adapter unlimited count?) or ViewFlipper? Or maybe there is a third solution (the best one).
Can you put some links to examples. :)
If you are only showing 1 item at a time, use ViewPager
If you want to show multiple items on the same page, use RecyclerView.
For calendar, it seems more close to ViewPager

ViewPagerIndicator not updating after setCurrentItem()

I'm trying to make an app for a local event to allow referees to quickly judge performance. Right now, I'm using a view pager that will not allow them to advance the page without inputting the results necessary in the page. I also have the page auto advance after they have input results.
I also have a ViewPagerIndicator (the line one) that doesn't update after setCurrentItem() is called. I tried calling notifyDataSetChanged() after setCurrentItem(), but that didn't seem to help.
Page advancing code:
if(pager.getMaxPage()<pager.getCurrentItem()+1){
pager.setMaxPage(pager.getCurrentItem()+1);
}
pager.setCurrentItem(pager.getCurrentItem()+1);
pager.getIndicator().notifyDataSetChanged();
I extended viewpager to store it's indicator.
Edit: To be clear, if I comment out the above code, and allow it to advance by swiping at all times, the indicator updates fine.
Ok, dumb mistake. If anyone sees this and has this issue, set your onPageChange listener to your indicator, not the ViewPager itself.

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

ViewPager + recycling views?

I'd like to create a gallery of photos that swipe left and right. At first I took a look at Gallery, but it's marked as deprecated.
http://developer.android.com/reference/android/widget/Gallery.html
We're told to try ViewPager instead. But the PagerAdapter class doesn't handle recycling of views for us (like a standard ListView), does it?
http://developer.android.com/reference/android/support/v4/view/PagerAdapter.html
Is it up to us to build the recycling mechanism?
Thanks
But the PagerAdapter class doesn't handle recycling of views for us
(like a standard ListView), does it?
No, and I think it's because it was built assuming you are using different layouts for each of the page.
Also, as it is not being scrolled as fast as a ListView (you cannot "fling" a ViewPager to skip multiple pages), I think it doesn't need to have to recycle.
This HorizontalListView is great, i used it to do exactly what you want.
see the link in the edit on this question The link in the Edit, and the answers give you some possible ways to solve.
There is also a HorizontalListView online somewhere if you search for it that makes a fine replacement for Gallery and does recycle its views.

Categories

Resources