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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:46:19+00:00 2026-05-27T21:46:19+00:00

There is a similar question on SO but i reckon my problem lies elsewhere

  • 0

There is a similar question on SO but i reckon my problem lies elsewhere or I’m missing something rather fundamental here.

I do have a unique ID set for my dialog : static final int DAYS_DIALOG_ID = 1;

I also have a class member variable : private TextView textViewSelectDayOfWeek;

In my overriden method onCreate(), i have :

textViewSelectDayOfWeek = (TextView) findViewById(R.id.textViewSelectDayOfWeek);
textViewSelectDayOfWeek.setOnClickListener(this);

So basically, i caputre my TextView defined in XML file in a variable and i set it’s listener.

In my onClick(view v), there’s a switch with the following case that is supposed to handle clicks on the TextView that is supposed to handle opening my dialog (do note that the aforementioned switch uses v.getId()):

case R.id.textViewSelectDayOfWeek:
            showDialog(DAYS_DIALOG_ID);
            break;

My overriden method onCreateDialog(int id) also contains a switch statement that uses the ID provided. The case that handles this particular problem-causing dialog is the following:

case DAYS_DIALOG_ID:
            final CharSequence[] daysOfWeek = { "@string/stringMonday"}; // 7 days, skimming unimportant stuff
            return new AlertDialog.Builder(this)
            .setTitle("@string/stringSelectDayDialogTitle")
            .setMultiChoiceItems(daysOfWeek,
                                    new boolean[] {true, true, true, true, true}, // Sets first 5 days as checked by default
                                    new DialogInterface.OnMultiChoiceClickListener() {
                                                        public void onClick(DialogInterface dialog, int day, boolean isChecked) {
                                                            Toast.makeText(getApplicationContext(), daysOfWeek[day], Toast.LENGTH_SHORT).show();
                                                        }
                                   })
                                   .create();

Now, if i click on the TextView with ID textViewSelectDayOfWeek, my app crashes.

I tried Toasting a message in onClick() right before i call showDialog(DAYS_DIALOG_ID) and the message does NOT appear before my app crashes.

What can i do to fix this problem ? I believe i mentioned all the important bits of my code but feel encouraged to request anything that might help.

Thanks in advance.

  • 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-27T21:46:21+00:00Added an answer on May 27, 2026 at 9:46 pm

    I certainly hope this helps someone.

    As thinksteep mentioned, the exception thrown is actually fairly useful 🙂

    I had an array of 7 week days and i supplied an incomplete array containing only 5 boolean values, which were to define whether the day is checked or unchecked by default, thinking the remaining values would be initialized with a default value of some kind.

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

Sidebar

Related Questions

I know there is a very similar question here but I was hoping to
There seems to be a similar question to this on here but with the
There is a similar question here but regarding the class path. ClassNotFoundException com.mysql.jdbc.Driver I've
there is a year old, similar question - but in case there have been
There is a similar question here but it only covers some of the issues
There'a a similar question here but I couldn't make use of the answers in
there is a similar question in here but for some reason I cannot make
For the record: I found a similar question here but I have to elaborate
There is similar question to this one here but I guess that by this
I see there is a similar question asked here but I don't think it

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.