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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:59:49+00:00 2026-05-18T19:59:49+00:00

EDIT: i have added in all of my code (excluding package and imports…..) and

  • 0

EDIT: i have added in all of my code (excluding package and imports…..) and if i try to run it it crashes…… any ideas why?

public class BaseConverter extends Activity {
/** Called when the activity is first created. */
int inputBase;
int outputBase;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Spinner input_spinner = (Spinner) findViewById(R.id.InputSpinner);
    Spinner output_spinner = (Spinner) findViewById(R.id.OutputSpinner);

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
            this, R.array.base_numbers_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    input_spinner.setAdapter(adapter);
    output_spinner.setAdapter(adapter);

    input_spinner.setOnItemSelectedListener(new InputItemSelectedListener());

    output_spinner.setOnItemSelectedListener(new OutputItemSelectedListener());
}

public class InputItemSelectedListener implements OnItemSelectedListener {

    public void onItemSelected(AdapterView<?> parent,
        View view, int pos, long id)
        {
        /*  switch (Integer.parseInt(parent.getItemAtPosition(pos).toString())
            case ((Integer)parent.getItemAtPosition(pos)).intValue(); 
                inputBase = 2;
                break;
            case 8:
                inputBase = 8;
                break;
            case 10;
                inputBase = 10;
                break;
            case 16;
                inputBase = 16;
                break;
                */

        Toast.makeText(parent.getContext(), "You selected input base " +
                parent.getItemAtPosition(pos).toString(), Toast.LENGTH_SHORT).show();
        }

    public void onNothingSelected(AdapterView parent) 
    {
      // Do nothing.
    }
}

public class OutputItemSelectedListener implements OnItemSelectedListener {

    public void onItemSelected(AdapterView<?> parent,
        View view, int pos, long id) { 
      Toast.makeText(parent.getContext(), "You selected output base " +
          parent.getItemAtPosition(pos).toString(), Toast.LENGTH_SHORT).show();
    }

    public void onNothingSelected(AdapterView parent) {
      // Do nothing.
    }
} 

}

and now need to have a switch – case scenario that all revolves around what the value they selected it. they are all numbers (the choices) and are stored in an Integer array. How do i set up that switch-case correctly? i tried doing a simple thing like

 case ((Integer.parseInt(parent.getItemAtPosition(pos).toString())
  • 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-18T19:59:50+00:00Added an answer on May 18, 2026 at 7:59 pm

    So i figured it out. you need to make the array a STRING array and the use:
    ArrayAdapter adapter = new ArrayAdapter

    etc…..

    then use

    Integer.parseInt(parent.getItemAtPosition(position).toString());
    

    to find the numerical value of whatever you selected. NOTE: it must be all numerical or it will give you an error.

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

Sidebar

Related Questions

EDIT: i have added in all of my code (excluding package and imports.....) and
I have a piece of code: EDIT: The _penParams are initialized as the added
EDIT: I have fixed all but two warnings now, so thank you all for
I won't want to have edit any working sets. I just want a way
EDIT : I have altered the NSPredicate as recommended so that my fetch code
I'm trying to get started with Phonegap. I have added some code to applicationDidFinishLaunching
Disclaimer: I apologize that this question is so long. I have added code as
EDIT I have finally figured out the problem i have been having on my
EDIT: I have edited my post... Working on a project (c#), I have a
EDIT i have something like this in a file: imagecolor=0 arrayimagecolorcopy=0 arrayimagecolorcopy3d=0 when 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.