문제

I have a a database with more than 6000 entries. I am using this example http://eshyu.wordpress.com/2010/08/15/cursoradapter-with-alphabet-indexed-section-headers/ to display the contents. But now the activity isn't able to handle it. I get a ANR dialog every time. How do I efficiently handle this circumstance?

도움이 되었습니까?

해결책

It doesn't make sense to go through each entry and ask the indexer on wich section that entry belongs to. In your case, the Indexer might be doing 6000 binary searches. Then puting that result in a map that will have below 30 entries and doing many overwrites.

It's also not a good idea to abuse the sectionToPosition Map to create a section starting postion.

A. You either prepare a table containing the stats, which would be the best way to handle so much data.

B. You can use the database to count number of entries for each section and build your own section starting pos map.

SELECT UPPER(SUBSTR(LTRIM(side_a), 1, 1)), COUNT(*) FROM cards GROUP BY 1 ORDER BY 1 ASC;

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top