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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:41:56+00:00 2026-05-17T18:41:56+00:00

Since working with Android I’m curious about how I can let Android do everything

  • 0

Since working with Android I’m curious about how I can let Android do everything in respect to orientation change (layout vs. layout-land).

Currently I have to feed the correct number of db columns and views to the cursor adapter. Is this the correct way or do I miss something? How do you guys do that?

Please have a look at the two SimpleCursorAdapter where I feed the same layout name of both existing layouts (there’s on in layout and one in layout-land). The only difference is the additional db column “type” and the additional view “R.id.activities_row_text3”.

Is this the correct way?

Cursor cursor;
SimpleCursorAdapter simpleCursorAdapter = null;
if ((cursor = db.fetchActivities(connection)) != null) {
    startManagingCursor(cursor);
    int orientation = getResources().getConfiguration().orientation; 
    if (orientation == Configuration.ORIENTATION_PORTRAIT) {
        simpleCursorAdapter = new SimpleCursorAdapter(
                                      this,
                                      R.layout.activities_row,
                                      cursor,
                                      new String[] {
                                          "name",
                                          "time" },
                                      new int[] {
                                          R.id.activities_row_text1,
                                          R.id.activities_row_text2 });
    } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        simpleCursorAdapter = new SimpleCursorAdapter(
                                      this,
                                      R.layout.activities_row,
                                      cursor,
                                      new String[] {
                                          "name",
                                          "time",
                                          "type" },
                                      new int[] {
                                          R.id.activities_row_text1,
                                          R.id.activities_row_text2,
                                          R.id.activities_row_text3 });
    }
    if (simpleCursorAdapter != null) {
        setListAdapter(simpleCursorAdapter);
    }
}
  • 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-17T18:41:56+00:00Added an answer on May 17, 2026 at 6:41 pm

    It would be better to create simpleCursorAdapter only once, while starting Activity. Then you can use method SimpleCursorAdapter.changeCursorAndColumns() (or bindView()) when change orientation occurs. You may need to invalidate list to see changes (notifyDataSetInvalidated()).

    To avoid restarting activity when orientation change occurs, see Handling orientation changes yourself

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

Sidebar

Related Questions

I'm currently working on migration of iPhone project to Android. And since my dev
I'm working with the Android NDK, and since it does not currently support the
I am working on an application for android and we since we have lots
I'm working on an Android application with ListView/GridView. Since I set an onClickListener on
Since yesterday everytime I open my layout Editor in Eclipse for the Android UI
I am currently working on Android application, I am unable to connect to Internet
I'm working on a Android application that involves a lot of XML layout files.
Working as an .NET developer since I know myself and just bought an Android
I'm currently working on a framework for Android which includes an ORM. I'm planning
I am currently working on building an Android app for my Rails backend. I

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.