Tablelayout with massive data android - java

What is the best way to create a table layout or recyclerview/listview/gridview in android that can pull a lot of data around 1000 rows and around 50 columns each row without to crash ?
I want to show it like excel sheet nothing special just show data of course with scrolling both ways.

TableFixHeaders project on github has an implementation with both Adapter an Recycling of views, plus handles scrolling wery nicely. And is quite easy to modify to suit your needs.
This is not so uncommon request, so it has been done numerous times. I am sure you can find other implementations if this one is not right for you.

I saw a similar question on SO a few months ago, and I was interested to see if I could develop a solution.
My concept was to start with a ListView for vertical scrolling and view recycling. Each list item is a HorizontalScrollView to show a table row with many columns. The trick here is to listen to each HorizontalScrollView for swipe events and then scroll every HorizontalScrollView in sync with the view being swiped.
I have a proof-of-concept project on Github here:
klarson2/android-table-test
Downsides: The project was set up for Eclipse, so you can't open it directly with Android Studio. There is still a small bug with event handling that I haven't got around to fixing. Another limitation is that each cell view in the horizontal LinearLayout must be a fixed size so that the columns will line up correctly.
However, the example uses a 4MB .csv file with 50 columns and over 10,000 rows for a data source proving that it is possible to display an enormous table in an Android app with responsive two-way scrolling.

Related

How to increase the height of list row using fragments?

I am working with fragments and created simple basis list and everything is working fine. But there is one thing that I can't do my self. I want to increase the height of the each row to cover the most of screen of any device. I know how to do in activities but I am not familiar with fragments. Any one can find a way for me?

Android Best Practice: Dynamically adding buttons to a ViewPager or Pre-Instantiating Them?

So I have a question about best practice for dynamically creating and sizing buttons within a ViewPager, based on a changing external state.
Essentially, I have a scrolling view and I want my ViewPager to contain a number of buttons of a specific size and count depending on what part of the scrolling view is currently visible.
My question is about deciding the best implementation of this feature, I see two options: would it be simpler to
Constantly create and scale new buttons whenever the scrolling view moves
Make the viewpager itself contain a scrollview and fill it with all of the pre-scaled buttons on app startup. Then, whenever the user scrolls the main scrollview the viewpager's scrollview (which contains the buttons) will scale programatically
Any ideas on which would be the simpler and more robust system?
Not much of an answer but I will leave a comment for ya! Basically you can do it either way, both aren't to difficult to accomplish, however I would probably go the dynamic route because it will always scale correctly. Doing a set amount will only work until devices become larger, or if you are targeting tablets or tvs then it will start to become extremely messy in the xml file for the layout. Dynamically adding also gives you far more control and saves time later on, you can simply change a number and have 100 more then going through and manually adding even 10. Hope this helps!

How to display multiple Tiles dynamically Android

I have to display multiple tiles on the same screen. Each Tile contains header,contents, and footer that would be set dynamically. So each Tile would be display with dynamic data.
How can I develop a program in android SDK for TABLETs
Just to get you started, you could have a look at Fragments (and Activity's) or perhaps even a ViewPager.
All these tips require a certain base knowledge on Android, though, just as #aneal commented on your question.

Android layout in java code

i'm making an app that requires indefinite textviews and images. i'm trying to implement a Pulse News app UI but having a hard time implementing one. so i thought of an idea to make a UI like that with the use of textviews, imageview and horizontal scroll view.
textview string values are from parsed xml online and images or the imageviews will be images from a specific directory in the sdcard that my app is using.
can anyone give me ideas how can i do it without using an xml layout or is there any or other options or ways for doing this? thanks...
You can create a viewgroup with one textview and an image. Then it can be added dynamically to your layout many times. This can be done by creating objects in a loop. You can change the content in each viewgroup at the time of inflation.
though i dont know what exactly how pulse new app looks like, but by going through your question (horizontal scroll view in particular) I guess you want to implement a "Gallery" type implementation where in you can swipe left/right on page basis.
If my assumption is correct then you will like to see to ViewPager of android backward compatiblity pkg.

ListView vs Nested Layout [Pros/Cons]

I'm working on an android application and I have run into a decision that I can't decide on one way or another. I was hoping someone could shed some light on the common practices and any theory to back them.
Here's the issue:
I want to have a list of items with images and text like table...
Country -.-.-.-.-.-.- Pop -.- SqrMi
[img] US -.-.-.-.-.-.- xxx -.-.- xxxxx
Now the debate I'm having is whether or not to use a listview to display the data or instead nest a layout that is scrollable and just display the data that way.
Why would I even consider a nested layout? Flexibility. I can design the dividers, possibly throw in a couple graphs above/below the list. Vary the height of each of the list items (like what if I want to show a graph in one list item and no graph in the next), etc.
I'm not sure if I'm breaking the generally accepted methods here. Can anyone shed some light on this?
The only major problem you will have when using nested layouts is memory consumption. ListView reuses its children so it doesn't create more children then it can display at a single moment. This description is a little simplified but I hope it shows the purpose of the ListView. Also ListView implements its own fast scrolling so it doesn't have to measure all its children to determine its size. And ListViews use adapters to populate themselves with data. It's a nice and convenient way to obtain data.
On the other hand if you create a ScrollView with a lot of views inside it'll be slow, difficult to populate with data and it'll require a lot of memory to create all of the child views even if you don't ever see some of them.
And about flexibility of the ListView. You can store different types of view in a single ListView and you'll be able to vary the height of each of this views.
All the things you have described for your "nested layout" is achievable with ListView. Just use different types of rows, use headers/footers in adapter.
And as already Pixie said, ListView is much more memory efficient and faster.

Categories