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 8951657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:42:52+00:00 2026-06-15T13:42:52+00:00

I’m trying to do horizontal swiping using a cursor but I’m just not grokking

  • 0

I’m trying to do horizontal swiping using a cursor but I’m just not grokking something, and hopefully someone here can help me understand.

I’ve got an activity that shows a list of items. It uses a ListView that is backed by a custom CursorAdapter, and that adapter is managed by a LoaderCallback. This is all standard stuff.

When the user clicks an item in the list, I want to show detailed information about that item. Currently I start a new activity, passing the ID of the selected item. This activity would load information about the item from a database. Again, standard stuff.

Now, going back and forth between the list of items and clicking an item to show more detail about that item is not the best user experience, and it would be preferable to allow the user to click an item to display its information, then allow swiping to show detail about the next or previous item in the list.

So I assume that when an item is clicked in the ListView, I need to start an activity that contains a ViewPager. This ViewPager is backed by a PagerAdapter that is responsible for fetching views at the appropriate position.

So I’d like to pass the CursorAdapter used in the list activity to the detail activity, and then implement a PagerAdapter that traverses the cursor to show the detail for the current item in the view pager. This seems simple enough: getItem(pos) would call cursor.moveToPosition(pos) then create a Fragment from the cursor, etc.

But (1) I’m not sure how to pass a CursorAdapter to an activity, as I don’t think it can be serialized for passing within a bundle and (2) I’m hesitant to pass a CursorAdapter to another activity anyway because there’s no LoaderCallbacks attached to manage the lifecycle.

One possible solution is to start the new activity and have that activity perform a new search to get an equivalent cursor to the cursor found in the list activity. For example, the list activity may have shown the items matching “title=foo”, so when item 10 is clicked we create a new detail activity that shows information about item 10, but also performs a “title=foo” search to obtain a cursor that can be used in horizontal swiping. But that means I’m performing the same search twice: once in the list view, and once in the paging view. This may be an issue if the search takes some time.

I could also store the cursor in some global static area (such as Application) but that seems fraught with peril as well.

There’s also Parcelable but I assume this means that I am serializing the cursor on one side and deserializing it on the other side. For large lists it may be more efficient to just perform the search again to get a new cursor.

I’m sure this is a common scenario, so I’d like to know what is best practice for managing cursors across multiple activities, or if some other approach may be better.

  • 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-15T13:42:53+00:00Added an answer on June 15, 2026 at 1:42 pm

    No. please don’t be passing any cursor or cursor adapters or anything like that to other activities. At some level of the process, you must have had to pass the activity’s context for an object’s creation. If that object somehow made into another activity using another’s context, things’d probably go bonkers.

    Moreover i don’t see why you need the adapter itself in the first place. Isn’t there a way that you could use just the cursor (re-instantiate) the same cursor for your new activity, pass the position clicked in and make your PagerAdapter and then pre-select the detail position that you want to view? just like what you said but you dont need a new search, pass the position in the intent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
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 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 have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.