pagination in listview

前端 未结 4 569
深忆病人
深忆病人 2020-12-20 06:57

Thanks in advance.

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 i

相关标签:
4条回答
  • 2020-12-20 07:24

    Kindly provide the logic/sample source code on how to implement the pagination if anyone has already implemented.

    See CommonsWare EndlessAdapter.

    0 讨论(0)
  • 2020-12-20 07:35

    Using the LIMIT keyword from MYSQL you can achieve pagination.

    LIMIT allows you to control the number of rows returned by query:

    Example:

    to show first 10 records

    SELECT * FROM Student LIMIT 10    //for first time
    

    to show rows between 10 and 20

    SELECT *FROM Student LIMIT 9, 10 //after showing the records first time
    

    LIMIT works for SQLiteDatabase also

    0 讨论(0)
  • 2020-12-20 07:39

    You can use something like:

    • Page 1:

      SELECT * FROM YOUR_TABLE LIMIT 20 OFFSET 0
      
    • Page 2:

      SELECT * FROM YOUR_TABLE LIMIT 20 OFFSET 20
      

    Reference: http://sqlite.org/lang_select.html

    0 讨论(0)
  • 2020-12-20 07:42

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

    "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."

    Here's what you can do:

    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

    0 讨论(0)
提交回复
热议问题