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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:59:17+00:00 2026-05-25T13:59:17+00:00

I used before setListAdapter with simple_multiple_choice to make listview with checkboxes. And then I

  • 0

I used before setListAdapter with simple_multiple_choice to make listview with checkboxes.

And then I did to get size and chosed positions:

SparseBooleanArray checked = list.getCheckedItemPositions();
cont = list.getCheckedItemPositions().size();

if (checked.get(i)) 
{
...

But now I needed more control on the layout, so i’m doing the listview on the xml, something like:

<listview>
<checkboxes id=.../>
</listview>

using setAdapter to those ids.

The listview is correctlyt populated (as before), problem is, now the SparseBooleanArray don’t work. Thar variable ‘cont’, gives me 0, and ‘checked’ is null.

To make sure that ‘list’ is ok:

int len = list.getCount();

It gives me a right value.

What’s the problem?

  • 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-25T13:59:17+00:00Added an answer on May 25, 2026 at 1:59 pm

    You need to Implement custom List Adapter.

    public class YourAdapterName extends BaseAdapter{
    
    private Context mContext;
    private DataType mValuestoShow;//Use your DataType to pass values to adapter. 
    
    /**
     * Constructor to be called to initialize adapter with values.
     * @param context
     * @param vector
     */
    public YourAdapterName(Context context, DataType data){
        mContext = context;
        mValuestoShow = vector;
    }
    
    public int getCount() {
        if(null != mValuestoShow){
            return mValuestoShow.size();
        }
        return 0;
    }
    
    public Object getItem(int position) {
        if(position < mValuestoShow.size())
            return  mValuestoShow.get(position);
        else
            return null;
    }
    
    public long getItemId(int position) {
        return 0;
    }
    
    
    
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder ;
        if(convertView == null){
            LayoutInflater li =(LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = li.inflate(R.layout.your_layout, null);
            holder = new ViewHolder();
            holder.txt_name = (TextView) convertView.findViewById(R.id.name_txt);
            holder.checkBox = (Checkbox) convertView.findViewById(R.id.checkbox);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
    
        holder.txt_name.setText(getItem(position).toString());
        holder.checkBox    // Do your task with checkbox.
        return convertView;
    }
    
    class ViewHolder {
        TextView txt_name;
        Checkbox checkBox;
    }
    
    }
    

    your_layout.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width = "fill_parent"
        android:layout_height = "wrap_content"
        android:padding = "10dp" >
    
    <TextView
        android:id = "@+id/txt_type1"
        android:layout_width = "wrap_content"
        android:layout_height = "wrap_content" />
    
    <CheckBox
        android:id = "@+id/checkbox"
        android:layout_width = "wrap_content"
        android:layout_height = "wrap_content"
        android:layout_alignParentRight="true" />
    
    </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In C, I did not notice any effect of the extern keyword used before
I've used UPX before to reduce the size of my Windows executables, but I
This is the way I get to prevent funA,funB,funC, etc.. for being used before
I understand that the @ symbol can be used before a string literal to
I am asking about the best tool that you used before to convert a
I have a lengthy JavaScript file that passes JSLint except for used before it
I'm trying to replicate a template I've used before with a member function, and
I used it before, and was reminded of it when someone asked about a
I've used NUnit before, but not in a while, and never on this machine.
I've never used SOAP before and I'm sort of new to Python. I'm doing

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.