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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:38:17+00:00 2026-05-30T01:38:17+00:00

This is my first post on stackoverflow, so feel free let me know if

  • 0

This is my first post on stackoverflow, so feel free let me know if I’m doing anything wrong.

I’m working on making an android app. For one of my menu activity’s I need some sort of widget that will allow the user to pick a number from a predefined set. (ie: {50, 100, 200, 500, 1000, 2000})

I looked at the Spinner, SeekBar, and NumberPicker Widgets, and here’s the problems I’ve found with each.

  • The Spinner seems to only allow strings.
  • The SeekBar and NumberPicker don’t seem to easily allow preset values.

Would any of these widgets work for what I’m trying to do? If not, is there another widget that might work better? If not, then how would you recommend I go about this?

Thanks!

Edit:

I tried using a spinner and the Integer.parseInt function. I got a null pointer exception:

02-11 18:21:23.823: E/AndroidRuntime(359): Caused by: java.lang.NullPointerException
02-11 18:21:23.823: E/AndroidRuntime(359):  at com.Package.Jigsaw.PuzzleActivity.onCreate(PuzzleActivity.java:20)

Line 20 of PuzzleActivity is the one where I’m declaring numPc.

Here’s the relevant bits of code:

Menu Activity:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.new_puzzle);

    //final Gallery gal = (Gallery) findViewById(R.id.opt_img);

    final Spinner numPc = (Spinner) findViewById(R.id.opt_numpc);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
            this, R.array.opt_numpc_options, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    numPc.setAdapter(adapter);

...snip...

        Button start_btn = (Button) findViewById(R.id.start_puzzle_btn);
    start_btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            Intent i = new Intent("us.kniffin.Jigsaw.OPENPUZZLE");
            //i.putExtra("img", gal.getSelectedItem());
            //i.putExtra("numPc", numPc.getSelectedItem());
            i.putExtra("numPc", Integer.parseInt(numPc.getSelectedItem().toString()));
            //i.putExtra("rot", rot.getSelectedItem().toString());
            //i.putExtra("connType", connType.getSelectedItem().toString());
            startActivity(i);

        }
    });

Main Activity (PuzzleActivity):

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final PuzzleView v;
    Dimension numPcXY;

    // TODO: update this line to read in options
    int numPc = (Integer) savedInstanceState.get("numPc");  

    // TODO: update this line to read in options
    picture = BitmapFactory.decodeResource(getResources(), R.drawable.test_pic);
    picture = Bitmap.createScaledBitmap(picture, picture.getWidth()/3, picture.getHeight()/3, false);

    // Do some math to do a case statement to determine numPcX and numPcY 
    numPcXY = calcXYpieces(numPc, picture);

    // Create the puzzle
    pieces = new PuzzlePieceSet(picture, numPcXY.getX(), numPcXY.getY());

    v = new PuzzleView(this, pieces);
    setContentView(v);

    pieces.scramble();
}
  • 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-30T01:38:18+00:00Added an answer on May 30, 2026 at 1:38 am

    I figured out my issue.

    The problem lies in this line:

    int numPc = (Integer) savedInstanceState.get("numPc");
    

    I should be using something like this:

    Bundle extras = getIntent().getExtras();
    int numPc = (Integer) extras.get("numPc");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first post to stackoverflow so if I've done anything wrong I
This is my very first post on StackOverflow. Basically, my app starts by checking
This is my first post on Stack Overflow so please exuse (and feel free
this is my first post here on stackoverflow and am very impressed by the
This is my first post to stackoverflow, so bear with me. :) I am
This is my first post on stackoverflow, hello everyone! My first venture into jQuery
this is my first post here on StackOverflow and I'm quite excited about it
This is my first post on StackOverflow, so please be gentle... I have some
This is my first post on stackoverflow, I hope one of many! My question
this is my first post on stackoverflow. Hopefully I am not disturbing anybody... :)

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.