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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:17:47+00:00 2026-06-05T12:17:47+00:00

I have seen many examples but none is according to my problem…in my case

  • 0

I have seen many examples but none is according to my problem…in my case i have a custom listview with custom adapter the checkboxex are primarily hidden and when option menu button is clicked the checkboxes get visible and the focusability is also set to true and listview no more receive list item click listener…i also have code to save the states of the checkboxes in SparseBooleanArray but the biggest problem is that in the getView() as it doesnt call on checkbox check so the check state is wrongly saved for example if i have firstly 5 items in my list view…the position from the
public View getView(int position,View convertView,ViewGroup parent) will be 6 beacuse the last item will be at position 6.so in my code

@Override
    public View getView(final int position,View convertView,ViewGroup parent)
    {
        //currentPosition=position;
        Log.v("Position",""+position);
        Log.v("ConvertView", ""+convertView);
        View row=convertView;

        if(row==null)
        {
            LayoutInflater inflater=((Activity)context).getLayoutInflater();
            row=inflater.inflate(layoutResourceId, parent,false);
            holder=new Feedbacks();
            holder.lvGuestName=(TextView)row.findViewById(R.id.guestName);
            holder.checkBox=(CheckBox)row.findViewById(R.id.clearCheck);

            holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener()
            {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
                {
                    if(isChecked)
                    {                           
                        checks.put(position, true);
                        System.out.println("checking at pos:"+position);
                    }
                    else
                    {                           
                        checks.put(position, false);
                        System.out.println("unchecking at pos:"+position);
                    }

                }                   

            });


            row.setTag(holder);

        }       
        else
        {               
            holder=(Feedbacks)row.getTag();

        }

        if(showCheckbox)
        {
            holder.checkBox.setVisibility(View.VISIBLE);        
        }
        else
        {
            holder.checkBox.setVisibility(View.GONE);
        }
        holder.lvGuestName.setText(feedbackList.get(position).getGuestName());
        holder.checkBox.setChecked((checks.get(position)));
        System.out.println("seting check at pos:"+position);    
        return row;                                     

    }

}                   

now when on if(isChecked)
{
checks.put(position, true);
System.out.println("checking at pos:"+position);
}

now even if i click on the 0 position item it will get the position to be 6
i know it because when checkbox is checked/unchecked the getView() will not called and hence checks.put(position,true); will not get the respective position…
i know i can easily do it with on listitem click with checkbox focusability false but im curious to learn new things thats why just want to know if any one know the according to my way how can i get the position of the respective checkbox checked in the listview…Any kind of help will be most appreciated and valuable for me…
Thanks in advance

  • 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-05T12:17:49+00:00Added an answer on June 5, 2026 at 12:17 pm

    In your code, you have wrong if condition so changed your code like and changed OnCheckedChangeListener to onClickListener.

     @Override
        public View getView(final int position,View convertView,ViewGroup parent)
        {
            View row=convertView;
            Feedbacks holder = null;
    
            if(row==null)
            {
                LayoutInflater inflater=((Activity)context).getLayoutInflater();
                row=inflater.inflate(layoutResourceId, parent,false);
                holder=new Feedbacks();
                row.setTag(holder);
            }       
            else
            {               
                holder=(Feedbacks)row.getTag();
            }
    
            holder.lvGuestName=(TextView)row.findViewById(R.id.guestName);
            holder.checkBox=(CheckBox)row.findViewById(R.id.clearCheck);
    
            holder.checkBox.setOnClickListener(new OnClickListener()
            {
                @Override
                public void onClick(View v)
                {
                    if(holder.checkBox.isChecked())
                    {                           
                        checks.put(position, true);
                        System.out.println("checking at pos:"+position);
                    }
                    else
                    {                           
                        checks.put(position, false);
                        System.out.println("unchecking at pos:"+position);
                    }
    
                }
            });
    
            if(showCheckbox)
            {
                holder.checkBox.setVisibility(View.VISIBLE);        
            }
            else
            {
                holder.checkBox.setVisibility(View.GONE);
            }
    
            holder.lvGuestName.setText(feedbackList.get(position).getGuestName());
            holder.checkBox.setChecked((checks.get(position)));
            System.out.println("seting check at pos:"+position);    
            return row;                                     
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen many posts on this subject, but none have been answered, and
I have seen many Q's on this subject but none are exactly what I
I have seen many parcelable examples so far, but for some reason I can't
I have seen many reportlab graphing examples. Generating the graph is not the problem,
In Python I have seen many examples where multiprocessing is called but the target
i have a general question about properties and ivars. ive seen many different examples
Greetings everybody. I have seen examples of such operations for so many times that
I have seen many articles and Questions/Answers Regarding Lock Escalation but following things are
I have seen many answers on stackoverflow, but I didn't find an answer that
I have seen many souce codes but I have never ever come across a

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.