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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:42:46+00:00 2026-05-20T13:42:46+00:00

i have this check box in a alertdialog. when i try to check the

  • 0

i have this check box in a alertdialog. when i try to check the state of the checkbox, the application force closes. any idea why?

LayoutInflater factory = LayoutInflater.from(NewActivity.this);
        final View textDisplayView = factory.inflate(R.layout.nearestlocs, null);
        final AlertDialog.Builder newAlert = new AlertDialog.Builder(NewActivity.this);
        newAlert.setView(textDisplayView);

        final CheckBox checkBoxLab = (CheckBox) findViewById(R.id.checkboxlab);
newAlert.setPositiveButton("Display on Map",
                new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {

                if(checkBoxLab.isChecked()){
                    libDisplayFlag = true;
                }

error log

 03-13 08:01:58.273: ERROR/AndroidRuntime(6188): Uncaught handler: thread main exiting due to uncaught exception
    03-13 08:01:58.292: ERROR/AndroidRuntime(6188): java.lang.NullPointerException
    03-13 08:01:58.292: ERROR/AndroidRuntime(6188):     at com.isproj3.NewActivity$3.onClick(NewActivity.java:158)
    03-13 08:01:58.292: ERROR/AndroidRuntime(6188):     at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
    03-13 08:01:58.292: ERROR/AndroidRuntime(6188):     at android.os.Handler.dispatchMessage(Handler.java:99)

xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout android:orientation="horizontal"
        android:gravity="center" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:layout_weight="1">
        <CheckBox android:id="@+id/checkboxlib" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="Library"
            android:gravity="left" android:textColor="#FF0000"
            android:paddingBottom="5px" android:textSize="07pt" android:checked="true" />
        <TextView android:id="@+id/librarytext" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:gravity="center"
            android:paddingBottom="5px" android:textSize="8pt" />
    </LinearLayout>
</LinearLayout>
  • 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-20T13:42:47+00:00Added an answer on May 20, 2026 at 1:42 pm

    I think the problem is that you have to specify in which view to find the id

    Try this

    final CheckBox checkBoxLab = 
                       (CheckBox) textDisplayView.findViewById(R.id.checkboxlab);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a check box in my registration form like this: <form name=reg id=reg
I have a table where each rows has a check box. This code works
http://img175.imageshack.us/img175/4295/tableissue.png http://img175.imageshack.us/img175/4295/tableissue.png Here's the picture to begin with. I have this check box, that
I have this code that will check the top level checkbox if the checkboxes
I have this code that I want to a) run when the check box
In my html.beginform I have this checkbox that I want to persist. I'm not
I have this HTML code which simulates a dropdown multi-checkbox <div> <div class=select> <span>Select
I have this js code: $(#startSearch).live(click, function(event) { $(input:checkbox[name='searchId']:checked).each(function() { var searchId = $(this).val();
I have this case <WrapPanel> <CheckBox>Really long name</CheckBox> <CheckBox>Short</CheckBox> <CheckBox>Longer again</CheckBox> <CheckBox>Foo</CheckBox> <Slider MinWidth=200
I have inserted this form with multiple checkbox items which collects some values, What

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.