开发者

How to load a lot of elements to a ListView?

I have a query vs a local SQLite DB that returns thousands of records in my Android app. How can I populate a ListView without b开发者_如何转开发locking it? I think I have to replicate what happens in apps like Twitter where data is retrieved in block of records, but I don't know what is the right way to do.


I am thinking that maybe memory might be an issue as well?

You might want to take a look at this ...

100K Items listview


Do some threading to not have your entire app working on one thing.

Threading

Simple Example(the above link breaks it down even more):

public void onClick(View v) { 
 new Thread(new Runnable() {    
public void run() {      

//Do SQL Load Here   

}  
}).start();}


Well I think you can use Paging concept. Just like you see in different applications. Let's say, it downloads first 50 items then when you reach at the end of the ListView it get the next 50 items again in the thread and so on.... Its quiet easy and you can have the control as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜