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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:51:15+00:00 2026-05-16T03:51:15+00:00

I am attempting to get my app to open a settings menu screen and

  • 0

I am attempting to get my app to open a settings menu screen and return. The problem I am having is when in the settings page, upon pressing the back button, the app closes. I am VERY new to programming in general after fighting this for about 8 hours I am ready to ask for help!

Here is the code I have written

`package com.bowersoftware.connecttozcu;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;

public class ConnecttoZCU extends Activity {

private Spinner mEngineSpinner;
private Spinner mUnitsSpinner;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mEngineSpinner = (Spinner) findViewById(R.id.engineSpinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
            this, R.array.engine, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mEngineSpinner.setAdapter(adapter);

}

private void ConnectSettings() {
    setContentView(R.layout.settings);
    mUnitsSpinner = (Spinner) findViewById(R.id.unitsSpinner);
    ArrayAdapter<CharSequence> settingsadapter = ArrayAdapter.createFromResource(
            this, R.array.units, android.R.layout.simple_spinner_item);
    settingsadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mUnitsSpinner.setAdapter(settingsadapter);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.option_menu, menu);
    return true;
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.scan:
        Toast.makeText(this, "Scan", Toast.LENGTH_LONG).show();
        return true;
    case R.id.settings:
        Toast.makeText(this, "Settings", Toast.LENGTH_LONG).show();
        ConnectSettings();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

}`

I am sure it is something silly I am missing but just can’t figure it out.

Thanks, Jason

  • 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-16T03:51:16+00:00Added an answer on May 16, 2026 at 3:51 am

    ContactsSetting should be separate Activity.

    At the moment you have single Activity, so when you press Back button the application is closed.

    To start new activity use:

    startActivity(new Intent(this, ContactsSetting.class));

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

Sidebar

Related Questions

I'm attempting to get my first ASP.NET web page working on windows using Mono
I am attempting to get the X Window at a certain location on screen.
i am attempting to get my android app to work on both phone type
I get errors like this when attempting to run unit tests under App Engine
I’m attempting to get the users location for a mobile web app, if their
I am attempting to get users facebook name etc via an app I am
I am attempting to get an on progress display on the screen while a
Hoping this question will get answered. Basically I am attempting to open an executable
I am attempting to get a rails 3.0.5 app up and running at http://blastoserver.com/
While attempting to get an old svn dump of a project under git control,

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.