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

  • Home
  • SEARCH
  • 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 4267128
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:51:23+00:00 2026-05-21T06:51:23+00:00

I feel like I’m missing something basic, and I’m actually kind of embarrassed asking

  • 0

I feel like I’m missing something basic, and I’m actually kind of embarrassed asking this question. But that’s what happens when you start learning a new platform…

I have a ListViewActivity that is populated via a CursorAdapter. When a list item is clicked, I start a new Activity to display the details for that item. What I want to do is enable flinging/swiping to iterate through the items from the detail activity. I don’t want to fully populate a ViewFlipper, as there is no hard-coded limit to the number of items in the List, and it just seems wasteful. Is there some way to intercept the fling gesture/trackball movement, and reset the detail activity with the next/previous item detail?

My ListViewActivity just sets up a Cursor (via managedQuery) and the associated CursorAdapter, with an OnListItemClick that calls startActivity with the appropriate Intent.

public final class ModelList extends ListActivity {

    private Cursor m_models = null;
    private ModelAdapter m_adapter;

    @Override
    public void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(m_models == null) {
            m_models = managedQuery(Model.CONTENT_URI, Model.PROJECTION, null, null, Model.DEFAULT_SORT_ORDER);
        }
        m_adapter = new ModelAdapter(this, R.layout.modelitem, m_models);
        setContentView(R.layout.forcelist);
        setTitle(R.string.activity_list);
        setListAdapter(m_adapter);
    }

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        Log.d(getPackageName(), "Clicked item id:" + id);
        if(id < 0) {
            startActivity(new Intent(Intent.ACTION_EDIT, Model.CONTENT_URI));
        } else {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Model.CONTENT_URI + "/" + id)));
        }
    }
}

My detail Activity seems pretty straightforward; it’s simply a RelativeLayout with a number of Views set up to display the details of the item based on the Intent’s Uri.

public class ModelDetail extends Activity {

    private Uri mUri;
    private FactionHelper factionHelper;
    private static String mCostFormat;
    private static String mDescriptionFormat;
    private ModelAdapter.MarAdapter marAdapter;

    @Override
    public void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.modeldetail);
        setTitle(R.string.activity_detail);
        mCostFormat = getBaseContext().getResources().getString(R.string.modelCostFormat);
        mDescriptionFormat = getBaseContext().getResources().getString(R.string.modelDescriptionFormat);
        mUri = getIntent().getData();
        factionHelper = new FactionHelper(getBaseContext());
        populateData();
    }

    protected void populateData() {

        TextView name = (TextView) findViewById(R.id.modelName);
        TextView description = (TextView) findViewById(R.id.modelDescription);
        // ... More finding Views and populating data ...
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        populateData();
    }

}
  • 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-05-21T06:51:23+00:00Added an answer on May 21, 2026 at 6:51 am

    Just pass the ID of the current record to the details activity. This will then query the details for the ID given and get a Cursor for that record.

    Then create a class which extends ViewSwitcher (the user will only be able to see one details at a time, so we only need 2 views at any one time). In your custom view switcher class add a method similar to:

    class MySwitcher extends ViewSwitcher {
        ...
    
        long currentRowId;
        long nextRowId;
        long previousRowId;
    
        public void setItemDetails(long rowId) {
            final View nextView = this.getNextView();
    
            currentRowId = rowId;
            /* Get the next/previous record IDs with a query like
             * "SELECT row_id FROM table WHERE row_id < "+currentRowId+" ORDER BY row_id DESC LIMIT 1;" (Previous)
             * "SELECT row_id FROM table WHERE row_id > "+currentRowId+" ORDER BY row_id ASC LIMIT 1;" (Next)
             */        
    
            // Do something with nextView, like set some text or something
            // You could get a cursor based on the rowID with
            // "SELECT * FROM table WHERE row_id = "+currentRowId+" LIMIT 1;"
            ((TextView) nextView.findViewById(R.id.myTextView)).setText("Details for item #" + rowId);
            this.showNext();
        }
    }
    

    If you don’t want an animation the first time setItemDetails is called then use setAnimateFirstView(false) on the ViewSwitcher.

    Then you need to add an OnTouchListener to detect drags/swipes, and then call setItemDetails with the next/previous row ID when you detect a horizontal swipe — you might want to set a different animation depending on whether you are moving to the next or previous item.

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

Sidebar

Related Questions

I feel like this is a dumb question and I'm missing something, but I
I feel like I should know this, but I haven't been able to figure
I feel like this is a stupid question because it seems like common sense
I feel like i am completely missing something because I am not able to
I feel like I'm missing something simple here (as usual). I'm trying to read
I feel like a bit of a newbie posting this, but anyway: I have
I feel like i've done this a ton of times, but i can't for
I feel like I'm missing something very simple here. I have Eclipse set up
I feel like this will end in a facepalm moment but I've been banging
I feel like a fool, but here goes: public interface IHasErrorController{ ErrorController ErrorController {

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.