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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:13:26+00:00 2026-05-29T17:13:26+00:00

I have a GridView on Android I populate with custom images. When the user

  • 0

I have a GridView on Android I populate with custom images. When the user clicks on an image, it goes to a different activity. This works perfectly.

The only thing I would like to fix is that whenever the user makes the selection, the GridView scrolls back to top. I would like to stay on the same position, so when the user goes back to the activity with the GridView, it shows the last scroll position.

Is it possible?

I tried putting a listener on scroll events, but obviously, last captured event is a scroll to the top so I can’t use that to move back the scroll where it’s supposed to be.

Thanks in advance!

Update: forgot to mention a very important point. I am stuck with API 7. So I don’t have smoothScrollToPosition.

  • 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-29T17:13:29+00:00Added an answer on May 29, 2026 at 5:13 pm

    Try something like the following:

    private int _savedGridPosition = 0;
    private GridView _gridView;
    
    ...
    
    @Override
    protected void onSaveInstanceState (Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt("grid_position", _gridView.getFirstVisiblePosition());
    }
    
    @Override
    protected void onRestoreInstanceState (Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        if(savedInstanceState != null && savedInstanceState.containsKey("grid_position")) {
            _savedGridPosition = savedInstanceState.getInt("grid_position");
        }
    }
    
    @Override
    protected void onResume() {
        _gridView.smoothScrollToPosition(_savedGridPosition);
    }
    
    @Override void onPause() {
        // set in onPause() too since onRestoreInstanceState() is only
        // called when the Activity is destroyed and recreated.
        _savedGridPosition = _gridView.getFirstVisiblePosition();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create image slideshow in android. I have many images in android
I want to make Activity like this using GridView. And this Activity have only
In my android app I have a gridview that I want to show images
I have an android gridview which i'm using some custom scrolling going on in,
I have created bg3.9.png image following this tutorial http://developer.android.com/guide/developing/tools/draw9patch.html but when i put it
I have a GridView defined like this: <asp:GridView ID=myGridView ruant=server> <asp:BoundField DataField=myField /> <asp:CommandField
I have the following LinearLayout with a GridView in it: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=match_parent
I'm currently working on an Android application. I wish to have a GridView on
I have created one gridview and use custom adapter for that. I added two
i have a grid view which contain images when click on one image it

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.