I'm developing for GoogleTV and I have created a dynamic table with 3 columns (using TableLayout), that shows the first 10 results fetched by HTTP from a Website.
As the user starts scrolling through the elements in the table (only rows are selectable, not columns), I want more results (rows) to be fetched and presented instantly (something like Google Reader).
To achieve that I'm using an AsyncTask that fetches more results from the Website, and adds them to the table. The problem is that I find it's behavior a little bit sluggish and unnatural, so I think that I may not be using the right approach.
Is there a better alternative to using TableLayout + AsyncTask? I have chosen TableLayout instead of ListView because I want to display the results in a "table-like" manner so it's easier to absorb the information.
Thanks for the replies.
Related
I am currently making a custom data table using advanced datatable package. Now managed to make it looked good, following the design I was given except one, how to make the last row different than the rest, fixed one where even if the user navigate to next page of table, the last row will still be there. Pretty much like this.
(sorry for the squared censors...)
I am trying to make the last row look like the "Total" row, so to make something like this in advanced data table? Or any other suggestion for a better paginated data table package?
In my app I download from the net some data I need to arrange in a table way.
I already know dimensions: about 26 rows and 6 columns, anyway data can change across subsequent calls so I have to create this table in a dynamic way.
As it is a table I though using a TableLayout (never used before), on the other hand I could simply use a list view, using for the single item a 6 elements linear layout with horizontal orientation.
ListView intrigues me because it is an adapter view (I think I'll store this data in a sqllite db, later) so populating it is quite simple and straightforward, anyway I don't know if it is the best for my problem.
What is your opinion?TableLayout, ListView or other?
When it comes to performance, I think you should use ListView because ListView support Recycling of view and you can check this and this post for more detail regarding Recycling of view.
Hope it helps :)
A ListView is a collection of layouts that are automatically displayed one below the other. The developer adds new items through a piece of code in the Activity. An example is the address book where you have lots of contacts one after the other.
A TableView on the other hand is defined in the layout file and does not only need to contain elements below or above each other but can also arrange elements on the left or on the right. A TableView is exactly what it says: A table with rows and columns.
here's a similar question that might answer what you want to know
Following on from this question:
ideal database field for calling data to
I have realised that I might be able to simplify my need for information to be brought to the screen by using a Dialog or a Custom Dialog, and by one of these methods I may call the whole finished page from a database instead of using static strings into the layout filling in specific fields with data like I am currently.
There could be a few hundred items or pieces of data to be called up in my App So am I correct with this assumption or do I need a specific other method to acheive this?
I am looking to call a custom dailog from a database so I can call a whole page of information complete but am unsure of limitations on this data wise or even if my sqlite database manager is even good enough for this task, each page will be called up "complete" where as before I was trying to have a template with the unchanging data (coke pepsi etc.)already included and appearing on every "result" page and then blank fields populated with data retrieved from a sqlite database (Litres size etc...) I am unsure which path to take : either make the page complete including all data like an image Or do I stick with my original plan to have a template screen with unchanging fields already in place and the changing information to be populated as needed from a Sqlite Database? hope this makes sense sorry if I was too vague with my question originally Im still learning.
Your question is vague but I'll risk an answer:
If you want to make a dialog like the image you posted on your previous question then this is the way to do it:
Create a custom dialog that will have as content a LinearLayout(with 3 TextViews representing the header labels in your image: COMPONENT, TYPE and AMOUNT, this will be somewhat identical to the list row layout below) + a ListView where the actual data will be shown.
Create a layout file for your ListView row to use(like the LinearLayout above will contain 3 TextViews for the drink name, type number and amount number).
When the dialog needs to be shown just get from the database all the drinks names, types and amounts and bind it to the ListView with one of the adapters based on a Cursor(like a SimpleCursorAdapter)
Getting the values from the database and binding them to many TextViews is not recommended(If you have many(I saw few hundred items or pieces of data)), also your dialog could be called a lot of times by the user in a short period of time and you don't want to do this binding each time for many views.
either make the page complete including all data like an image
Please don't do this!
I am building one app which is a copy of a website.
In that website they showed some bulk of data in a table view (with multiple rows and columns)
I want to show the same bulk of data in android mobile.
But the problem is which widget will be reliable to show large amount of data (like table). And which widget will give efficient and professional look.
Please suggest some widget or views
For a static (predefined/known)
content you can use TableLayout,
as in this example,
For dynamically populate the table
you should use a GridView
(considering as an option the
ListView as well: if you don't
have many columns, an proper item
renderer would be more efficient).
Building a dictionary application I need a ListView that shows over 100k items. I want to let the user scroll as much as needed.
What's the best practice for searching and showing words?
Is it ok to show 150,000 words in the ListView (for pereformance)?
If not how to add 100 other words after the user reaches to the end of the list?
Currently I show 50 words previous and 50 words next of searched word.
Thank you.
(second answer in response to clarification about performance)
There are different ways to do this based on where your data is.
The best way is to have your data in a sqlite database and use a CursorAdapter. Android then manages the fetching of your data and won't fetch data that isn't currently being shown on the screen.
If your words are in an array in memory, try ArrayAdapter or SimpleAdapter.
The Adapter interface, from which all of the above classes inherit, is designed to provide good ListView performance regardless of the number of objects in the list.
One built-in way to allow fast scrolling is via the fast scroll thumb. In your xml, set:
android:fastScrollEnabled="true"
on your ListView, or try:
listView.setFastScrollEnabled(true)
listView.setFastScrollAlwaysVisible(true)
RecyclerView is very good for this. I have developed an open source library especially designed to scroll through large list with extreme speed. In fact it can move well in excess of 1000 items per second both in single and multiple column layouts You can check out the repo here: https://bitbucket.org/warwick/hgfastlist or you can checkout the OpenGL version here: https://bitbucket.org/warwick/hgglfastlist. Here is a demo video on Youtube: https://www.youtube.com/watch?v=oz7aeAlOHBA&feature=youtu.be
Even if you don't want to use this library, there's loads of code to read through in the demo app that will give you good ideas.