列表视图中的分页 [英] pagination in listview

查看:29
本文介绍了列表视图中的分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提前致谢.

我正在开发一个汽车评论应用程序,用户可以在其中登录并显示数据库中的所有评论.所有的数据都首先存储在 MYSQL 数据库中.我正在使用 json 连接到 MYSQLdatabase 和 SQLiteDatabase.但问题是,登录后应用屏幕巨大没有.数据来自服务器,并被插入到我们的 SQLite 数据库中.

I am developing a Car Review Application, where user can log in and displayed all the review from the Database. All the the data is being stored in MYSQLdatabase first. I am using json to connect to the MYSQLdatabase and SQLiteDatabase. But the problem is that, after log in the application screen huge no. of data is coming from the server and it is being inserted in our SQLite Database.

在从数据库中检索并以列表视图显示在应用程序屏幕中之后,在列表视图中显示所有数据需要更长的时间.在这种情况下,我使用 SimpleCursorAdapter 从数据库中检索所有数据.

After that it is being retrieved from database and displayed in the Application Screen in a list view, it is taking a longer time to displayed all the data in list view. In that case, I am using a SimpleCursorAdapter to retrieve all the data from database.

那么有没有像分页之类的方法可以使数据检索更快.请提供一些源代码来帮助我.

So is there any way like pagination or something like that to make the data retrieval faster. Please help me by giving some source code.

推荐答案

您可以将异步任务的概念与 SimpleCursorAdapters 一起使用.

You can use the concept of Asynchronous tasks along with SimpleCursorAdapters.

AsyncTask 支持正确且轻松地使用 UI 线程.此类允许在 UI 线程上执行后台操作和发布结果,而无需操作线程和/或处理程序."

"AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers."

您可以这样做:

1) 在第一个查询中只检索第一个 10/15 个项目.2) 在用户签出前 10/15 项时,触发另一个查询作为后台任务.

1) Retrieve only 1st 10/15 items in the 1st query. 2) Fire another query as a background task, while user is checking out first 10/15 items.

这肯定会让用户体验更快

This will certainly make the User experience faster

这篇关于列表视图中的分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆