Scroll before ScrollView is loaded - android

Hello, I have a question,
Is there any possibility to skip the first scroll's that occur before gridView is loaded?
To get only those when user really scrolls my list?
I am loading more, and that scroll before any user action is messing up.

How are you loading the gridView?
If you load it using addView you probably won't have problem.
In my opinion the best solution is to create a scrollView that contains a LinearLayout (for example vertical), then add at this LinearLayout a list of LinearLayouts (horizontal), and every layout contained in list contains yours elements.

Related

What should be design approach - ListView Vs LinearLayout

I have an activity which shows these three things in order.
ViewFlipper (User can fling it left/right)
EditText
ListView (List view can have n number of rows. lets limit it for 100. each row has images which get downloaded asynchronously)
I want that user can scroll vertically so I put above three item in single relative layout and that in to scrollView
<RelativeLayout>
<ScrollView>
<RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Problem with this approach
ListView and scroll view together is bad user-experience. When List will cover all screen user will have problem in scrolling complete view itself.
Solution which I could think of
Disable Scroll on ListView and let it show all items (Is this good enough)
User addHeaderView (not sure how to use it)
Second Approach (Which I did and ran into problems).
Instead of using ListView add LinearLayout (replacement of listrow) dynamically.
Problem with this approach
Lot of ugly coding as there is no sophisticated adapter for such scenarios. Need to populate each LinearLayout and it creates more issue because I have async Image loading for every LinearLayout.
What could be better approach. Any alternates?
Do not use a ScrollView and a ListView together, this is a bad thing as mentioned by Romain Guy, the creator of ListView. The problem with you LinearLayout approach is performance: you will need to create n new Views, while the ListView just reuses existing ones.
The solution I could think of (in case it is not possible to make your Layout components to fit on the screen without scrolling), you could disable scrolling in your ListView and add "scroll up" and "scroll down" buttons, setting the onClickListener and OnLongClickListener to let the user control scrolling speed. Though this might be not the best approach. Consider re-disigning your layout so the components fit on a single screen. This is usually not a good user expierince to enable scrolling because of layout components not fitting on a single screen. Your could add a page more to your ViewFlipper and place your ListView there for example

ListView or recycle views myself?

I have an app which loads a boatload of images and displays them in a TableLayout which is inside a ScrollView. At run time I get the width of the layout parent and use that to determine how many images can go in each TableRow (all of the images are of a set size).
I'm concerned about memory issues when loading more and more images. I know ListView recycles its views but I don't know how to dynamically change number of views in each item. I am only aware of inflating XML which isn't going to change the number of views per item at run time.
So my question is what is easier - figuring out how to recycle views in my table by myself, or making a list's items change based on screen size? Just a link to a tutorial on how to do whichever is easier is good enough an answer for me.
I suggest you to use ListView with the ViewHolder approach (you can see it here: How to load the Listview "smoothly" in android).
The ListView, when scrolled, removes the views that are no more visible and gets the views that are about to become visible. This way, it's better than using a ScrollView and a TableLayout.

Scrollview inside listview issue in android

I am adding a listview inside a scrollview in xml that xml(Screen) is loading from the middle screen. In my design I have a top part like a textview and a list view and middle part like editext and bottom part like button. Page is loading from the middle part. If it scrolls I can only see the above part. I want to load the page from above part. Can anybody tell me what the problem is and how to resolve it?
Thanks
Use android:fillViewport="true" as an attribute in your scrollview tag and it will fill up the screen.
Actually there is no need to use ScrollView with ListView. Use ListView only, you will be able to scroll the items in a ListView.
You should never use a ScrollView with a ListView, because ListView
takes care of its own vertical scrolling. Most importantly, doing this
defeats all of the important optimizations in ListView for dealing
with large lists, since it effectively forces the ListView to display
its entire list of items to fill up the infinite container supplied by
ScrollView.
found it here
using smoothScrollTO(0,0) to fix the issue

Is it possible & efficient to put a LinearView and ExpandableListView inside a ScrollView

I'm making a GUI with two different parts. The first part (at the top) is composed of some banners, several fixed buttons. So I think using LinearLayout is the most straightforward way to implement. The second part is composed of several similar items grouped together which can be implemented by using ExpandableListView, I think.
However the problem is that the content exceeds the screen size. So I intend to put two of them into a ScrollView. I checked several sources, it seems that putting "ExpandableListView" inside a ScroolView is NOT possible, or not efficent, so I'm afraid...
Would you help to confirm if this is possible? efficient ?
If no, would you give me some recommendations for this layout design?
I'm indeed looking forward to your supports.
Sincerely.
If you have a fixed header at the top of a list, use ListView's header view feature.
Putting ListViews in ScrollViews fundamentally makes no sense and here is why:
ListView has one purpose: to efficiently display unbounded data sets. Since these can be extremely large (tens of thousands of items and more) you do not want to create a View for each item up front. Instead, ListView asks its Adapter for Views only for the items that currently fit in the ListView's measured space on screen. When an item's View is scrolled out of sight, ListView disconnects that View and hands it back to the adapter to fill out with new data and reuse to show other items. (This is the convertView parameter to an Adapter's getView method.)
ScrollView also has one purpose: to take a single child view and give it "infinite" vertical space to fit within. The user can then scroll up and down to see the full content.
Now given this, how many item Views would a ListView create for a 100,000 item Adapter if it had infinite height available to fill? :)
By putting a ListView inside a ScrollView you defeat ListView's key purpose. The parent ScrollView will give the ListView effectively infinite height to work with, but ListView wants to have a bounded height so that it can provide a limited window into a large data set.
Well Expandable List View itself has scrollable property by placing it in scroll view is really undesirable.As the both scroll would contradict and smooth scrolling can't be obtained in that case..
If we have any data to be shown prior or later to list...
Best way is to use header and footer view to list...
I recommend you use header and footer in your case.

How to create lazy loading in Horizontal scrollview

My application loads 10 image-thumbnails from server and set them into horizontal scrollview. When I swipe it to the last image, I would like to add lazy-loading element in the back of my horizontal scrollview and download next 10 more image in the background process.
My problem is -----> How I know the last image in horizontal scrollview shows on the screen?
I think the horizontal scrollview is so different from listview, because the listview uses adapter to control inside elements.
Thanks you so much
Maybe you can use a ViewPager http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html
This uses an adapter behind the scenes and you can do the trick where you set the count to a very large number.

Categories

Resources