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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:36:45+00:00 2026-05-15T18:36:45+00:00

EDIT: This problem may be related to BaseAdapter causing ListView to go out of

  • 0

EDIT: This problem may be related to BaseAdapter causing ListView to go out of order when scrolled


My main application screen uses a GridView to display a grid of icons. Each icon has an image, name, and Intent. I have the Activity set to handle orientation changes so I can change the background. The onCreate method sets up the GridView with 3 test icons that don’t do anything and a preferences icon which opens a PreferencesActivity:

super.onCreate(savedInstanceState);
setContentView(R.layout.main);

GridView gv = (GridView) findViewById(R.id.main_grid);
if (getResources().getConfiguration().orientation ==
        Configuration.ORIENTATION_LANDSCAPE)
    gv.setBackgroundResource(R.drawable.main_bg_horiz);
else
    gv.setBackgroundResource(R.drawable.main_bg);

ArrayList<Icon> icons = new ArrayList<Icon>();
icons.add(new Icon("Test 1", R.drawable.test1, null));
icons.add(new Icon("Test 2", R.drawable.test2, null));
icons.add(new Icon("Test 3", R.drawable.test3, null));
icons.add(new Icon("Preferences", R.drawable.perferences, new Intent(this,
        AlertPreferences.class)));
IconAdapter ia = new IconAdapter(icons);
gv.setAdapter(ia);
gv.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3){
        Intent i = ((IconAdapter)arg0.getAdapter()).getItem(arg2).getIntent();
        if (i != null)
            HomeActivity.this.startActivity(i);
    }
});

And the onConfigurationChanged is very simple:

super.onConfigurationChanged(newConfig);    
GridView gv = (GridView) findViewById(R.id.main_grid);

if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
    gv.setBackgroundResource(R.drawable.main_bg_horiz);
else
    gv.setBackgroundResource(R.drawable.main_bg);

The background changes just fine but the code introduces a new problem with the GridView. Whatever orientation I start the application in it works just fine. However, when I change orientation, the order of the icons in the GridView reverses. And when I rotate the screen back to the orientation it started in, everything goes back to normal. What’s going on here?

  • 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-15T18:36:45+00:00Added an answer on May 15, 2026 at 6:36 pm

    It was in fact a problem with the custom Adapter. The problem and solution are both here BaseAdapter causing ListView to go out of order when scrolled

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

Sidebar

Related Questions

I'm looking for a solution for this problem in C or C++. edit :
I think that this is a permissions issue but I am not sure and
I have some existing C code that uses ICMP raw sockets to do Ping
I have a long list of items where clicking on an item may move
Problem There is a program file that contains the following code snippet at some
In DirectShow, a media sample has two time-related properties: its time stamp and its
I'm currently struggling on getting my CheckBox es to properly center within my GridViewColumn
I have a bunch of URLs from an old site that I recently updated
I'm developing an app for WP7 (VS2010 Express for Windows Phone RTM and WP
My engine is executing 1,000,000 of simulations on X deals. During each simulation, 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.