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

  • Home
  • SEARCH
  • 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 6765477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:42:58+00:00 2026-05-26T14:42:58+00:00

Hi i setup a CheckedTextView but I can’t get the onClick event functioning. I

  • 0

Hi i setup a CheckedTextView but I can’t get the onClick event functioning.
I put the onClick code in the onCreate of the main.layout but I get a nullpointer at line 101, which is chkBox.setOnClickListener(new View.OnClickListener().
The Listview is created in the onPostExecute of a AsyncTask.
Can someone please help?

My CheckedTextView:

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"  
         android:id="@+id/listCheckboxview"  
         android:layout_width="wrap_content"  
         android:layout_height="wrap_content"  
         android:layout_weight="1" android:gravity="left"  
         android:textColor="#0075AB"  android:textStyle="bold"  android:textSize="14dip" 
         android:checkMark="?android:attr/listChoiceIndicatorMultiple"   
         android:clickable="true" 
         android:focusable="true" 
         android:text=""  
         /> 

My onClick event:

CheckedTextView chkBox = (CheckedTextView) findViewById(R.id.listCheckboxview); 
        chkBox.setOnClickListener(new View.OnClickListener() { 
        public void onClick(View v) 
        { 
            ((CheckedTextView) v).toggle(); 
        } 
    });
  • 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-26T14:42:59+00:00Added an answer on May 26, 2026 at 2:42 pm

    I put the onClick code in the onCreate of the main.layout but i get a nullpointer at line 101, which is chkBox.setOnClickListener(new View.OnClickListener()

    This means that chkBox is null, which means that Android is not finding R.id.listCheckboxview. Make sure you are calling findViewById() on the right thing (here, you appear to be calling it on the activity, but your question mentions a ListView). Also, try cleaning your project (Project > Clean from the Eclipse main menu, or ant clean from the command line), as sometimes the R constants get out of sync.

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

Sidebar

Related Questions

Setup Have you ever had the experience of going into a piece of code
Setup: I have two views that I need to respond to the touch event,
Setup: IIS7 serving ASP classic VB script code which generates a dynamic VSC page/file
I setup some stop watch calls in my code to measure some code blocks
setup: create table main(id integer unsigned); create table test(id integer unsigned,created datetime,text text); insert
Setup: I have attached an event handler on the WebBrowser control something like this...
Having an issue with CheckedTextView that I can't seem to find a solution. I'm
setup: mysql> create table main(id integer unsigned); mysql> create table test1(id integer unsigned,body text);
Setup I have an accordion layout containing a properties panel that nests two inner
Setup MVC 3 EF 4.1 Code First - Windows 7 Pro 64 Dev machine,

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.