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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:45:25+00:00 2026-06-06T23:45:25+00:00

Im trying to test the functionality of my spinner with a toast. I am

  • 0

Im trying to test the functionality of my spinner with a toast. I am having trouble because instead of toasting ShowTime, it force closes. my logcat is posted below the code. If anybody can help me read my logcat code and figure out whats wrong. Thanks in advance!

 public class Spinner extends Activity {
        Spinner bus;
        String GetTime;
        int ShowTime;

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

            final String[] Log_Array = new String[9];
            {
                Log_Array[0] = "5 min";
                Log_Array[1] = "10 min";
                Log_Array[2] = "30 min";
                Log_Array[3] = "50 min";
                Log_Array[4] = "100 min";
                Log_Array[5] = "300 min";
                Log_Array[6] = "400 min";
                Log_Array[7] = "500 min";
                Log_Array[8] = "600 min";

                bus= (Spinner) findViewById(R.id.timer);

                ArrayAdapter NoCoreAdapter = new ArrayAdapter(this,
                        android.R.layout.simple_spinner_item, Log_Array);
                bus.setAdapter(NoCoreAdapter);

                bus.setSelection(1);
            }

            bus.setOnItemSelectedListener(new OnItemSelectedListener() {

                public void onItemSelected(AdapterView<?> parent, View view,
                        int pos, long id) {

                    GetTime = parent.getItemAtPosition(pos).toString();

                    if (pos == 0) {
                        GetTime.equals(Log_Array[0]);
                        ShowTime = 5;
                    }
                    if (pos == 1) {
                        GetTime.equals(Log_Array[1]);
                        ShowTime = 5;
                    }
                    if (pos == 2) {
                        GetTime.equals(Log_Array[2]);
                        ShowTime = 5;
                    }
                    if (pos == 3) {
                        GetTime.equals(Log_Array[3]);
                        ShowTime = 5;
                    }
                    if (pos == 4) {
                        GetTime.equals(Log_Array[4]);
                        ShowTime = 5;
                    }
                    if (pos == 5) {
                        GetTime.equals(Log_Array[5]);
                        ShowTime = 5;
                    }
                    if (pos == 6) {
                        GetTime.equals(Log_Array[6]);
                        ShowTime = 5;
                    }
                    if (pos == 7) {
                        GetTime.equals(Log_Array[7]);
                        ShowTime = 5;
                    }

                    if (pos == 8) {
                        GetTime.equals(Log_Array[8]);
                        ShowTime = 6;
                    }
                    Toast.makeText(getApplicationContext(), ShowTime,
                            Toast.LENGTH_LONG).show();
                }

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

My LogCat

07-01 16:12:14.348: E/AndroidRuntime(21733): FATAL EXCEPTION: main
07-01 16:12:14.348: E/AndroidRuntime(21733): android.content.res.Resources$NotFoundException: String resource ID #0x5
07-01 16:12:14.348: E/AndroidRuntime(21733):    at android.content.res.Resources.getText(Resources.java:210)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at android.widget.Toast.makeText(Toast.java:258)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at com.settings.Settings$1.onItemSelected(Settings.java:88)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at android.widget.AdapterView.fireOnSelected(AdapterView.java:871)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at android.widget.AdapterView.access$200(AdapterView.java:42)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:837)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at android.os.Handler.handleCallback(Handler.java:587)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at android.os.Handler.dispatchMessage(Handler.java:92)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at android.os.Looper.loop(Looper.java:143)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at android.app.ActivityThread.main(ActivityThread.java:4196)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at java.lang.reflect.Method.invokeNative(Native Method)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at java.lang.reflect.Method.invoke(Method.java:507)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-01 16:12:14.348: E/AndroidRuntime(21733):    at dalvik.system.NativeStart.main(Native Method)
  • 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-06-06T23:45:27+00:00Added an answer on June 6, 2026 at 11:45 pm

    Toast has a convenience method that allows you to pass it a resource ID(integer) that is a pointer to a string resource.

    so this line of code:

    Toast.makeText(getApplicationContext(), ShowTime,Toast.LENGTH_LONG).show();
    

    is telling the program to make a Toast and fill it with the String resource that the Integer ShowTime is the ID for. In your project that String resource doesn’t exist so you are getting this exception.

    To fix you’ll need to use the makeText() method that takes a String as the second parameter, rather than an int. Like this:

    Toast.makeText(Spinner.this, String.ValueOf(ShowTime),Toast.LENGTH_LONG).show();
    

    Also note that your Activity is a context, so you should be using this (your activity) instead of the getApplicationContext() method. And because you are inside of a Listener object declaration you need to put the name of your Activity infront of this

    Edit: I would also suggest that you do not name your activity “Spinner”. Since there is a UI component object that is called Spinner this adds a level of connfusion. I would refactor it and change the name of the Activity to SpinnerActivity if I were you.

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

Sidebar

Related Questions

I'm having trouble with this piece of functionality I'm trying to have an accordion
I'm trying to make jumping functionality in my Movement test. My character jumps and
I am trying to test a functionality, which inserts few details into the DB.
This is some sample test app i trying to learn Parallel.Foreach Loop functionality static
I am trying to establish new SDL Tridion UI 2012 functionality on some test
I'm trying to test the functionality of a web app by scripting a login
I'm trying to make a simple program to test the new .NET async functionality
I'm trying to test the functionality of a webservice using ruby with minitest and
In trying to test some sign-in/out functionality I want to delete some information from
I am trying to add template functionality to my vector class, after already having

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.