Table data showing - android

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).

Related

Need to make a table: which is better for performances?

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

Dynamic table content display with AsyncTask

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.

Displaying data via table format (Android)

I have 2 columns of data in my database in Android application. I want to display this data via a table format in my application. Please help me.
For example, I have employeename and department coulmns in the database. I want to retrieve this data and show it in a table format like a table with 2 columns. One side employeename and next column their respective department in my Android application.
Unless you want user interact with the table, you can use webview and make it load table html. Advantage of this method is that you can make it as fancy as you want.
If you want interaction with the table, you'd better use listview with customized row layout, or even gridview would work too.

What is the most efficient way to populate a listview?

I have an app which mains view is a listview. Each item consist of multiple textviews and imageviews. Now, what is the most efficient way to populate these items? String arrays? External text file? Online text files?
for example this is an item in the listview:
The listview will contain over 50 items and these items will increase every week. So it should be as easy as possible to add new items!
First of all you pick an efficient way that works for YOUR project.
I would recommend just using an SQLite database for such.
You could use Text files, but you have a database availible for such, so i would recommend using it.
Here is more info on SQLite and how to get started using it.
EDIT:
Also you could possibly use online text files. And just read the information from them. This may take some time when populating the list, so i would recommend doing this in he background, and trying to write the information to a abase.
Using SQLite and getting started

listview adapter implementation

With the application i am working on i came with the following problem. I have a listview that should display data from a data base table. There are two scenarios that could happen:
Scenario one - the database table is filling dynamically and the listview also should dynamically display table's information e.g to grow depending on table size.
Scenario two - the table has been already filled and the listview has to just display the content
So the problem is how to accomplish this behavior using ListView and ListAdapter.
So far i have solution for each scenario but no for the two together.
Scenario one - Use AsyncTask and ArrayAdapter. In doInBackGround query the db periodically and pass the result to onProgressUpdate, than just fill the ArrayAdapter with the newly added values. But when came scenario two i query all the table than copy all values to the ArrayAdapter in one step which is pretty slow.
Scenario two - Query the db again the just use CursorAdapter. But in this case i can't update the ListView dynamically using CursorAdapter.
So any ideas how to implement this using one adapter, or just should i use ArrayAdapter and CursorAdapter depending on the case ?
Scenario one - the database table is
filling dynamically and the listview
also should dynamically display
table's information e.g to grow
depending on table size.
Try:
Scenario 1a: Whoever is getting the data not only puts it in the database, but tells the activity "here's some new data to display".
Databases are great data stores but are lousy pipes. Your "Scenario one" tries to use the database as a pipe -- instead, pipe around it.
Now, if the case is that you have both in-the-database data and new data coming in, you'll need to stitch those datasets together. You can use my MergeAdapter for it: give it two ListAdapters, one representing your existing data (perhaps a CursorAdapter) and one representing the new data (perhaps an ArrayAdapter). It will render them as a combined entity.

Categories

Resources