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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:08:16+00:00 2026-06-02T12:08:16+00:00

I’m developing an Android 3.1 application. I’m very very new on Android development. I

  • 0

I’m developing an Android 3.1 application. I’m very very new on Android development.

I have a ListActivity which items are defined as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <CheckBox
        android:id="@+id/itemCheckBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</LinearLayout>

This ListActivity show a form’s list. User can select (checking its checkbox) one or more forms and download them.

When forms are downloaded I want to remove them from the list. To do it, I use updateFormsNotDownloaded at FormAdapter:

    public class FormAdapter extends ArrayAdapter<Form>
    {
        private Context context;
        private int layoutResourceId;
        private ArrayList<Form> forms;
        private ArrayList<Integer> checkedItemsPosition;
        private Button downloadButton;

        public ArrayList<Integer> getCheckedItemsPosition()
        {
            return checkedItemsPosition;
        }

        public String[] getSelectedFormsId()
        {
            String[] ids = new String[checkedItemsPosition.size()];
            int i = 0;
            for(Integer pos : checkedItemsPosition)
            {
                Form f = forms.get(pos.intValue());
                ids[i] = f.FormId;
                i++;
            }
            return ids;
        }

        /**
         * Called when selected forms has been downloaded and save it locally correctly.
         */
        public void updateFormsNotDownloaded()
        {
            for(Integer pos: checkedItemsPosition)
                remove(forms.get(pos.intValue()));
            checkedItemsPosition.clear();
            notifyDataSetChanged();
        }

        public FormAdapter(Context context, int textViewResourceId,
                ArrayList<Form> objects, Button downloadButton)
        {
            super(context, textViewResourceId, objects);

            this.context = context;
            this.layoutResourceId = textViewResourceId;
            this.forms = objects;
            this.checkedItemsPosition = new ArrayList<Integer>();
            this.downloadButton = downloadButton;
        }

        @Override
        public int getCount()
        {
            return forms.size();
        }
        @Override
        public View getView(final int position, View convertView, ViewGroup parent)
        {
            Log.v("FormAdapter", "getView.postion: " + position);
            View row = convertView;
            if (row == null)
            {
                LayoutInflater inflater = ((Activity)context).getLayoutInflater();
                row = inflater.inflate(layoutResourceId, parent, false);
            }

            Form f = forms.get(position);
            if (f != null)
            {
                CheckBox checkBox = (CheckBox)row.findViewById(R.id.itemCheckBox);
                if (checkBox != null)
                {
                    checkBox.setText(f.Name);
                    checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener()
                    {
                        public void onCheckedChanged(CompoundButton buttonView,
                                boolean isChecked)
                        {
                            //Form f = forms.get(position);
                            if (isChecked)
                            {
                                //checkedItems.add(f.FormId);
                                checkedItemsPosition.add(new Integer(position));
                            }
                            else
                            {
                                //checkedItems.remove(checkedItems.indexOf(f.FormId));
                                int index = checkedItemsPosition.indexOf(new Integer(position));
                                if (index > -1)
                                    checkedItemsPosition.remove(index);
                            }
                            downloadButton.setEnabled(checkedItemsPosition.size() > 0);
                        }
                    });
                }
            }

            return row;
        }
    }
}

Imagine I have the following list:

  1. Form 1. (Checked)
  2. Form 2.
  3. Form 3.

User select Form 1 and when forms is saved locally, and updateFormsNotDownloaded is called I see this:

  1. Form 2. (Checked)
  2. Form 3.

Why form 2 is checked? How can I uncheck all?

  • 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-06-02T12:08:18+00:00Added an answer on June 2, 2026 at 12:08 pm

    You should be checking to see if that position should be checked and manually setting the checked value for each. I don’t see anywhere that you are doing this..

    Ex.

    //we set the OnCheckedChangeListener to null so that setting the checkbox value doesn't trigger the checkedChangelistener
    //this may or may not be relevant for your project
    checkBox.setOnCheckedChangeListener(null); 
    checkbox.setChecked(checkedItemsPosition.contains(position));
    checkBox.setText(f.Name);
    checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener()
    {
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
          {
            //the rest of your code here
          }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.