Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9087773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:46:22+00:00 2026-06-16T21:46:22+00:00

I’d like to use a ViewPager to show several items per page from a

  • 0

I’d like to use a ViewPager to show several items per page from a single Cursor (originally from a ContentProvider). The layout will be shown as a grid and will include images and text for each item. There will be frequent additions and deletions from the list which need to be reflected in the UI without having to rebuild the data structures (which may preclude some options below).

Current process:

  1. Instantiate cursor in main activity.
  2. Create my own Cursor Adapter class extended from PagerAdapter which takes in the cursor. The cursor is used to determine the number of pages the ViewPager will have through getCount() (and then adjusted according to how many items will be shown per page).
  3. In the Cursor Adapter getItem method, it creates the fragment which will eventually contain a subset of the list.

At this stage, I’m not sure which is the best method to take. Do I:

A. Pass the Cursor and an index to the Fragment to display the next page of results (e.g. having a setCursorIndex( Cursor, int ) method. (Does sharing Cursors across Fragments cause issues even if it’s in the same Activity?)

B. Pass in a list of ContentUris strings which would obtain the results. (Would this prevent updates to the list without having to rebuild?)

C. Build an arguments bundle containing the items (a list containing byte arrays for images, and text). (This seems inefficient due to the use of images.)

D. Re-create a new Cursor in each Fragment having received a starting index from the adapter. (Inefficient?)

Many thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:46:27+00:00Added an answer on June 16, 2026 at 9:46 pm

    IMHO, the answer is some combination of B and C.

    It is C, insofar as you create an arguments Bundle and give it to the Fragment, perhaps using the factory method pattern (e.g., newInstance()). This way, you have all that data in the fragment during configuration changes, if the fragment will be destroyed and recreated.

    However, “a list containing byte arrays for images, and text” seems inappropriate. If you already have Uri values (or String representation of Uri values) for the images, put those in the Bundle, and use a centralized image caching solution (such as this one or this one) for ensuring that you only load those images in when needed. Other smallish things (“and text”) can just go into the Bundle.

    Option A can probably work, but you have to be careful to take into account:

    • configuration changes (what happens when the user rotates the screen and your activity is destroyed/recreated?)
    • the implicit current-row pointer in the Cursor (each fragment will need to moveToPosition() before attempting to read any data)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I am confused How to use looping for Json response Array in another Array.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.