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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:53:11+00:00 2026-05-31T14:53:11+00:00

I got a complicated problem involving a ListView and some Intents on Android: I

  • 0

I got a complicated problem involving a ListView and some Intents on Android:

I have a ListActivity which contains many items. From another Activity, lets call it CallingActivity, I want to launch this ListActivity and scroll to a specific item. In the ListActivity some other Activites can be launched, lets call them AnotherActivity.

My current implementation is to store the item to which the ListActivity should scoll in the intent and then use the following code in the onStart() method.

if (getIntent().getExtras() != null && getIntent().getExtras().containsKey(EXTRA_EVENTNR)) {
        int p = getIntent().getExtras().getInt(EXTRA_EVENTNR);
        getListView().clearFocus();
        getListView().post(new Runnable() {
            @Override
            public void run() {
                getListView().setSelection(p);
            }
        });
    }

This solution has a huge drawback:

Suppose the following call-sequence:

  1. CallingActivity launches ListActivity with Intent [EVENTNR=123]
  2. ListActivity recieves the intent and scrolls to the right position.
  3. User continues to read and scrolls further down.
  4. AnotherActivity is launched from ListActivity
  5. The User presses the Back-Button
  6. The old intent (from 1.) is still present and gets passed again in onStart of the ListActivity.
  7. ListActivity scrolls to the same position again (same as in 2.)
  8. Scrolling of the User from 3. is lost

I think a Intent is the wrong solution for carrying the scroll-information. Intents are more for the contents of a activity and not for its display.

Is there another solution for passing the scrolling information which only gets applied once? Did I miss something?

  • 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-31T14:53:13+00:00Added an answer on May 31, 2026 at 2:53 pm

    What if you do getIntent().removeExtra() to remove your extra data?

    On the other hand it might be that putting the info into the Intent is an unnesessary complication as you don’t really need an Intent for that.
    Can it be a plain java object to store that info with API to set and reset it?

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

Sidebar

Related Questions

I've got a strange problem here. Assume that I have a class with some
I'm attempting to put together some basic report screens. I've got some fairly complicated
I've got a bit of a complicated set up. I specialise in XSLT which
I've got a project which requires a fairly complicated process and I want to
I've got a program where a lot of classes have really complicated configuration requirements.
I have got a server that controls a complicated industrial system. We need to
I have tried to ask a variant of this question before. I got some
I've got a really complicated html page and I've added some bookmark anchors at
I've got an ILookup generated by some complicated expression. Let's say it's a lookup
I'm using Rails with the JQuery plugin, and have some really complicated validations for

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.