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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:01:44+00:00 2026-05-24T13:01:44+00:00

The question is about android Spinners working when Gone and then Visible again. I’ve

  • 0

The question is about android Spinners working when “Gone” and then “Visible” again.

I’ve got a form where spinner is hidden (“Gone”) by default. If user checks checkbox, it appears and allows to choose something. The problem is when I do submit info from the form without touching the checkbox (i.e. default value is chosen from spinner), App crashes with nullpointer exception – despite I`m setting spinner as visible.

If I click checkbox (even twice, to make Spinner gone again) – everything works fine. If I use invisible instead of gone, everything works fine even without touching the button.

How to make it work with spinner “Gone” by default?

Here`s code on how checkbox behaves (onclick checkbox):

        case R.id.checkboxUseDefaultURLList:
        {
            final CheckBox checkBoxDefaultList = (CheckBox) findViewById(R.id.checkboxUseDefaultURLList);
            final TextView textViewEmpty = (TextView) findViewById(R.id.textBlank);
            final Spinner s2 = (Spinner) findViewById(R.id.spinnerURLList);
            if (checkBoxDefaultList.isChecked()) {
                textViewEmpty.setVisibility(View.GONE); // GONE
                textViewEmpty.invalidate();
                s2.setVisibility(View.GONE); // GONE
                s2.invalidate();
                }           
            if (!checkBoxDefaultList.isChecked()) {
                textViewEmpty.setVisibility(View.VISIBLE); // VISIBLE
                textViewEmpty.invalidate();
                s2.setVisibility(View.VISIBLE); // VISIBLE
                s2.invalidate();
                }
            break;
        }

here`s how I get values from Spinner (in onclick of “submit” button):

                    Spinner spinURLList = (Spinner) findViewById(R.id.spinnerURLList);
                spinURLList.setVisibility(View.VISIBLE);
                spinURLList.invalidate();
                spinURLList.setSelection(0);
                TextView chosenURLTV = (TextView) spinURLList.getSelectedView();
                String urlListSelected = chosenURLTV.getText().toString();

Any ideas why it crashes if I don`t click on checkbox before submitting?

  • 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-24T13:01:46+00:00Added an answer on May 24, 2026 at 1:01 pm

    It may be a problem of assigning the TextView the text in the spinner. Try:

    String urlListSelected = spinURLList.getSelectedItem().toString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about working with time in java, more specificly in Android.
Hello I have question about android spinner I have spinner which is populated by
Hello I have question about android spinner I have spinner which is populated by
I got a question about the usage of GWT-RequestFactory in Android. As a starting
I am working on an android project right now and have a question about
I have a comprehension question about Android Services. I have a Service that performs
I am about to start developing an Android application and had a question if
Question about subclassing in matlab, under the new class system. I've got class A
This question about Timers for windows services got me thinking: Say I have (and
First a little background about why I'm asking this question... I'm working on a

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.