Suppose I have a ListView displaying exactly 10 rows that is not intended to scroll.
When the user swipes, the next list of 10 rows would be displayed. The bottom of the ListView would say something like "page 2 of 3".
How can I indicate to users that they should swipe to get the next page?
A page indicator might be helpful like you said. I view-pager may be another option. In that case I would use: http://viewpagerindicator.com/
I think you are best off rolling your own solution using a ScrollView and/or a ViewPager
According to a GoogleIO presentation about ListViews, they are coded with many "behind-the-scenes" tricks in order to optimize performance.
When you start trying to modify how they work, then you end up with a complex widget that doesn't make use of its own complexity and optimizations.
Some type of vertical view pager could be good for what you see though.
Reference: http://www.youtube.com/watch?v=wDBM6wVEO70
Related
I am currently building an app using firebase.
I have an activity in which the background and UI are the same, but the page has only the contents that change inside according to the date.
It`s kind of some diary app.
I am worried about whether I need to ViewPager or not to use ViewPager, but if I have saved it somewhere and clicked on that date, I need to display the contents with setText(). I'm not sure about that how to do more optimization.
And when I scroll horizontally across the screen, I want to see the pages change with swipe-animation. Do I have to use viewPager? I mean I use one page but I want to give a fake animation effect as the page looks. If this helps optimally.
Anyway, So I'm looking for an example that uses viewPager with firebase recycler-view, but it's a bit hard to find. Is it better to use a fragment? with this?
Optimization has been troubling for weeks on issues.
I have a lot of questions, but I would like to hear good advice on these things.
I would appreciate it if you could explain it slowly and easily.
Thank you very much for reading.
Page has only the contents that change inside according to the date.It`s kind of some diary app. I am worried about whether I need to
ViewPager or not to use ViewPager?
Yes, Viewpager with FragmentStatePagerAdapter is a good choice here, as there may be many dates in your case with its own content.
Check out the below link, it explained very well how any why to use viewpager with tabLayout.
https://guides.codepath.com/android/google-play-style-tabs-using-tablayout
And when I scroll horizontally across the screen, I want to see the
pages change with swipe-animation. Do I have to use viewPager?
For animation between the page swipes, you can use pageTransformer.
Checkout this
https://developer.android.com/training/animation/screen-slide.html
and
https://medium.com/#BashaChris/the-android-viewpager-has-become-a-fairly-popular-component-among-android-apps-its-simple-6bca403b16d4
I'm making sort of a news feed, that is displayed below a static menu. To avoid the news feed from being scrolled in the tiny bit of space that's left after the menu, I wanted to scroll both the menu and the newsfeed at the same time.
Now I'm realizing this with a LinearLayout, so it doesn't scroll itself like the listview. But my question is, is using a LinearLayout, which from what I know doesn't reuse views like a listView, bad practice? How likely am I to get into memory issues, since the news feed can have A LOT of views, and they all contain images.
Many thanks!
Apparently there is a pretty good chance for you to get an OutOfmemmoryexception in no time with this approach,If you want to go with re-using the views
I suggest you should go with the new RecyclerViews in Android,
Go here for a tutorial on recycler views
I don't know if this qualifies to be an answer. But if you are using a LinearLayout with a header view and a ListView inside it, then there are no issues. Since the main worry you have is the news feed which would be recycled by the ListView. Neglecting to use view recycling is asking for trouble, and will likely break after 50 or so (Android hates images).
As for the header that must disappear. I would avoid putting it as the first item in a ListView as suggested in the comments, and rather have it static in the LinearLayout. And use a view translation and/or transparency to hide it. This keeps the option availible to display the header at any point, regardless of the list's scroll.
Do we get any benefits of implementing a ListView for which every item would have different layout? Would it be a better idea to put those items into ScrollView with LinearLayout instead?
Intuitively, it seems like using a ListView may still give better performance, though it might be negligible depending on the size of your content. Because the ListView inflates the views as it needs them, it seems like you might save some time by not parsing/rendering views that a user might never see. A long ScrollView with a bunch of views inside seems like it would take additional time when first launched, since the view hierarchy is more complex.
I do think Michael is mostly correct though, that the main advantage of a ListView is that views are reused, which saves on memory/processing. Unless you have a ton of content in the ScrollView, I suspect the performance difference is not significant, and will almost definitely be more complex -- in particular, having to create an adapter that knows how to create each view type for each row.
I don't understand why you may use ListView for this. Listview is a list of common data using the same layout if you click on it. Users depend on same/similar GUI patterns.
How about Sliding Tabs or the newer navigation drawer, link NavigationDrawer.
If you like sliding tabs, then I can give you more details.
I'm new programming in Android and i have many doubts about what type of classes can i use in my first app.
I want to do a level menu like cut the rope or angry birds. Only a title and a slider menu.
I think that can do with the two classes, but I'm not sure which is better, can you tell me the difference and which is better to use?
Many thanks.
ViewPager allows you to flip between pages of data (between views). You supply an adapter to generate the pages that the view shows.
But HorizontalScrollView is a container for other views that you can scrolled through, allowing it to be larger than the physical display.
I would go with horizontal scroll view.
EDIT : See FoamyGuy's answer in Angry Birds like scrolling menu where he exactly explains how to achieve such effect.
Suppose I have a list of data to be displayed. I know how to display it using a ListView And it is very simple and easy to do it that way. But I am looking for an alternative way to achieve the same. I don't expect to have more than 20 items in the data set I am planning for.
I was thinking of a number of squares that the user can swipe to see the next one etc, similar to some widgets on home screen.
I came across android.widget.StackView, any advice available for this?
You can try StackView (http://developer.android.com/reference/android/widget/StackView.html).
This is how the Gallery and Youtube widgets are rendered.
ListView is the best option for listing lots of data. It has very efficient loading property. But if you do not want it any specific reason, you have to use ScrollView and in ScrollView, you have to place a LinearLayout and in that LinearLayout, you have to place multiple LinearLayout(for each items of data).
Maybe you can use a ViewPager (available also for lower versions of SDK through compatibility pack).
http://developer.android.com/training/implementing-navigation/lateral.html - see also the project example top right of the page : EffectiveNavigation.zip
You can use a GridView, if you want to show multiple items on a page in a different fashion than in ListView.
You can also use ViewPager (from android 3.0, or with the support library) with your custom views.