I have a android app with a tableview with a lot of rows, about 2000 rows. When I do setData to the tableview, that takes a few seconds. If the user touches anything the app responds with the "Wait or force close" dialog. If I wait the app will work.
Is there a way to come around this? I have tried to do a: setTimeout(function() { tablewVIew.setData(data); }, 1); That didn't work. I have tried to append rows in smaller chunks. That resulted in longer and longer times. Seams like append 100 rows does "add 100 rows"... appends 100 rows.. "remove all rows, add 200 rows".
Any idea on how to prevent the "wait or force close"? Different thread would solve it but that is not possible?
2 Answers
Lets be honest, 2000 rows of data is intense and I would suggest finding a way to paginate that data. As a user I don't want to scroll through that (roughly 12 rows per screen on hdpi device with 40-45 height, with tabs and title bar, is 160+ screens of information).
Let me search, then return the results I want.
Categorize some how.
Hi Bill
You added in the comment the reason you need 2000 rows is because of the search bar.
It would be much more efficient to use the search bar as a search bar rather than as a filter as I suspect you are using it right now.
Whilst the table can use a linked search bar to filter the data, the amount of data you are asking it to play with is massive.
By disconnecting the search bar and handling the search yourself, you can call the database and run a filtered select statement - I assume your data is already in a sqlite database, if not it should be for this use.
For performance I would only search on the button press search from the keyboard. Also limit the results returned to a reasonable number like 50 or 100 max, if needed allow user to filter results, with a large data set your audience would probably like the ability.
I would also make sure you are using the tableviewrow property className for your rows, with a different value for each variation of row (probably only one), this will tell the operating system that it can cache the row structure and simply swap the data in and out when that rows worth of data is getting close.
Your Answer
Think you can help? Login to answer this question!