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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:36:40+00:00 2026-05-25T15:36:40+00:00

EDIT: Based on evolution of the problem, I edited this question. First of all,

  • 0

EDIT: Based on evolution of the problem, I edited this question.

First of all, I know there some similar questions, but each one of them has a specific difference, that makes the answer useless for me…

I really really appreciate if anyone can help me, I’m getting really desperate with this problem…

So the problem is: I want to populate a ListView with checkboxes, and can’t use simple_multiple_choice_mode (something like that) because I need to manually build my XML layout – so I’m using the list_item.xml file:

<?xml version="1.0" encoding="utf-8"?>
        <CheckBox 
xmlns:android="http://schemas.android.com/apk/res/android" android:paddingLeft="8mm"
android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:id="@+id/nomeAPP" style="?listItem">
        </CheckBox>

Problem is, if I use the simple_multiple (..) mode option, getCheckedItemPositions works fine. If don’t (as I have in the code below) getCheckedItemPositions comes null. So from what I read, it’s a common bug, that needs an handler as workaround. But I cant get the handler to work, I get an exception with java.lang.NullPointerException in the logcat.

Can anyone please help me?

I have this little pretty code:

this.setListAdapter(new ArrayAdapter<String>(this, 
                    R.layout.list_item, aux));

            list.setItemsCanFocus(false);
            list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
            list.setSelected(true);
            list.setClickable(true);
            list.setOnItemSelectedListener(new OnItemSelectedListener() {
                public void onItemSelected(AdapterView<?> arg0, View arg1,
                        int arg2, long arg3) {
                    //  Auto-generated method stub

                    Log.d("checked",""+arg2);        


                }

                public void onNothingSelected(AdapterView<?> arg0) {
                    // Auto-generated method stub
                }

            });


            CheckBox c = (CheckBox) findViewById(R.id.nomeAPP);
            c.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
                    CheckBox checkbox = (CheckBox)arg0; 
                    boolean isChecked = checkbox.isChecked();

                    if(isChecked == true)
                        Log.v("TAG", "true");
                    else
                        Log.v("TAG", "false");
                }
            });
  • 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-25T15:36:41+00:00Added an answer on May 25, 2026 at 3:36 pm

    Looks that was a bug in the use of setAdapter, which is solved using setListAdapter.

    Let’s see, documentation states that ListActivity should use

    list=getListView();
    <ListView android:id="@android:id/list"
    

    so forget about = “+@id(….

    now we can our activity knows “where” is the List and now we can use

    setListAdapter(new ArrayAdapter<String>(this, 
                          R.Layout.List_item, aux));
    

    and everything works fine.

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

Sidebar

Related Questions

Edit: This question was written in 2008, which was like 3 internet ages ago.
EDIT: This question is more about language engineering than C++ itself. I used C++
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know
Edit: This was accidentally posted twice. Original: VB.NET Importing Classes I've seen some code
I would like to display certain meta data fields in the edit form based
Edit: From another question I provided an answer that has links to a lot
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
Edit : Solved, there was a trigger with a loop on the table (read
EDIT I've just started skimming Codd's famous 1970 paper that started it all, that
I recently asked this question and worked out that the reason a single email

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.