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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:08:21+00:00 2026-05-25T16:08:21+00:00

I have a list view whose adapter is in a different class in a

  • 0

I have a list view whose adapter is in a different class in a different package. Now I have to get the data from database then I set Adapter for my list view using this data. So I have created an ArryList and pass this in the constructor of Adapter while seeting it for the list view. But the problem is that the data is repeating. eg.- there are 12 distinct Strings in the arraylist but what I get is -first five elements in order and after that the same five are being repeated. The count of data is always right but the position will always be 0,1,2,3,4 . I can not understand what the problem is . here is the code –

public class CheckboxAdapter extends BaseAdapter{

    LayoutInflater inflater ;
    ArrayList<String> mData = new ArrayList<String>();

    //constructor for lesion adapter
    public CheckboxAdapter (Context context, ArrayList<String> data){
        inflater = LayoutInflater.from(context);
        mData = data;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return mData.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null){
            Log.v("pos", ""+position);
            convertView = inflater.inflate(R.layout.e_lesion_liststyle, null);          
            final CheckBox cb = (CheckBox) convertView.findViewById(R.id.disease_lesion_checkbox);
            cb.setText(mData.get(position));
            cb.setOnClickListener(new OnClickListener() {           
                @Override
                public void onClick(final View v) {
                    cb.setButtonDrawable(R.drawable.check_box_1);
                }
            });
        }//end of if condition
        return convertView;
    }
  • 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-25T16:08:21+00:00Added an answer on May 25, 2026 at 4:08 pm

    try this.. just write all code out of the condition expect inflate code..

    @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null){
                Log.v("pos", ""+position);
                convertView = inflater.inflate(R.layout.e_lesion_liststyle, null);   
               }       //end of if condition
                final CheckBox cb = (CheckBox) convertView.findViewById(R.id.disease_lesion_checkbox);
                cb.setText(mData.get(position));
                cb.setOnClickListener(new OnClickListener() {           
                    @Override
                    public void onClick(final View v) {
                        cb.setButtonDrawable(R.drawable.check_box_1);
                    }
                });
    
            return convertView;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list view filled with data. I set up a context menu
I currently have a list view which has several rows of data and I
I have a databound list view and can set all the column widths manually
I have a list view that is displaying data using the gridview. This list
Revised: I have a list items on the page that I'm creating from database
I have a combo box inside a list view. And different items (rows) in
I have a ListView whose size is fixed to maximum of 10 items View
I have a list view control which at the moment only allows one item
I have a list view that is periodically updated (every 60 seconds). It was
Hello i have a list view control, While the form is being loaded i

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.