Android tableview force close

You must Login before you can answer or comment on any questions.

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.

— answered 10 months ago by Stephen Feather
answer permalink
3 Comments
  • Use an activity indicator to open right before setting data.

    hide the activity indicator in the postlayout event of the tableview.

    — commented 10 months ago by Stephen Feather

  • The reason for the rows are to use searchbar for the tableview. If there is no solution, I will go for a alternative search solution. Would still be interestion to know if there is a way around the "wait or force close" dialog beacuse of UI taking to long.

    — commented 10 months ago by Bill Martensson

  • There is a solution, an I gave it to you. Halt user interaction until the app is finished.

    Do so with an activity indicator (mentioned above) or (this is a second freebie) through a semi transparent view over the entire screen indicating to the user that something is happeneing, and remove it in the postlayout.

    That IS the solution for trying to load 2000 lines of data into a table view, whether in Titanium or in pure Java natively. Its just a huge amount of data to be processed.

    — commented 10 months ago by Stephen Feather

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!