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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:05:25+00:00 2026-06-02T10:05:25+00:00

how to modify this imageCheckBoxAdapter code in order to maintain status of checkBox when

  • 0

how to modify this imageCheckBoxAdapter code in order to maintain status of checkBox when scrolled(that is all the checkboxes which are checked should remain checked even after scrolling. Also the checked variables need to be stored in an array)?

class imageCheckBoxAdapter extends ArrayAdapter<String>
{
private final Context context;
private final ArrayList<String> values;
private final Map< String, SmbFile> obj;
static ArrayList<Boolean> checks=new ArrayList<Boolean>();
public imageCheckBoxAdapter(Context context,ArrayList<String> values,Map< String, SmbFile>obj) 
{
    super(context, R.layout.row_checkbox, values);
    this.context = context;
    this.values = values;
    this.obj=obj;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rowView = inflater.inflate(R.layout.row_checkbox, parent, false);
    TextView textView = (TextView) rowView.findViewById(R.id.text1_check);
    textView.setText(values.get(position));
    ImageView imageView = (ImageView) rowView.findViewById(R.id.icon_image_check);
    try
    {
        if((obj.get(values.get(position)).isFile()))
        {
            imageView.setImageResource(R.drawable.view_file_icon);
        }
        else
        {
            imageView.setImageResource(R.drawable.view_folder_icon);
        }
    }
    catch (SmbException e) 
    {
        Toast.makeText(context,"Network error",Toast.LENGTH_SHORT).show();
        Log.d("id1", "error1");
        e.printStackTrace();
    }
    return rowView;
}
}

row_checkbox.xml

<?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="wrap_content"
    android:padding="5dp" >
    <CheckBox
    android:id="@+id/checkBox1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:checked="false" />
 <ImageView
    android:id="@+id/icon_image_check"
    android:layout_width="50px"
    android:layout_height="50px"
    android:layout_marginLeft="5px"
    android:layout_marginRight="20px"
    android:layout_marginTop="5px"
    android:src="@drawable/view_file_icon" >
    </ImageView>
 <TextView
    android:id="@+id/text1_check"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@+id/label"
    android:textSize="30px" 
    android:typeface="sans">
    </TextView> 
</LinearLayout>
  • 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-02T10:05:27+00:00Added an answer on June 2, 2026 at 10:05 am
    class imageCheckBoxAdapter extends ArrayAdapter<String> implements View.onClickListener
    {
        private final Context context;
        private final ArrayList<String> values;
        private final Map< String, SmbFile> obj;
        private ArrayList<Boolean> checks=new ArrayList<Boolean>();
    
        public imageCheckBoxAdapter(Context context,ArrayList<String> values,Map< String, SmbFile>obj) 
        {
            super(context, R.layout.row_checkbox, values);
            this.context = context;
            this.values = values;
            this.obj=obj;
    
            for (int i = 0; i < values.size(); i++) {
                checks.add(i, false);
            }
        }
    
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View rowView = inflater.inflate(R.layout.row_checkbox, parent, false);
            TextView textView = (TextView) rowView.findViewById(R.id.text1_check);
            CheckBox chk = (CheckBox) rowView.findViewById(R.id.checkBox1);
            textView.setText(values.get(position));
            ImageView imageView = (ImageView) rowView.findViewById(R.id.icon_image_check);
            try
            {
                if((obj.get(values.get(position)).isFile()))
                {
                    imageView.setImageResource(R.drawable.view_file_icon);
                }
                else
                {
                    imageView.setImageResource(R.drawable.view_folder_icon);
                }
            }
            catch (SmbException e) 
            {
                Toast.makeText(context,"Network error",Toast.LENGTH_SHORT).show();
                Log.d("id1", "error1");
                e.printStackTrace();
            }
    
            chk.setTag(Integer.valueOf(position));
    
            // Set a listener for the checkbox
            chk.setOnClickListener(this);
    
            //Sets the state of CB, since we have the list of checked CB
            chk.setChecked(checks.get(position));
    
            return rowView;
        }
    
        @Override
        public void onClick(View view) {
            Integer index = (Integer)view.getTag();
            boolean state = checks.get(index.intValue());
    
            checks.set(index.intValue(), !state);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working with WCF how it should modify this DataContract or code: <DataContract()> Public Class
I want to modify this code which works pretty good but (or I don't
I want to modify this code so that the value is a variable and
I'm trying to modify this code ( http://code.google.com/p/pypng/source/browse/trunk/code/texttopng ) so that it can render
How can I modify this query to return results that exclude all records that
Is there an easy way to modify this code so that the target URL
I was wondering how I could modify this code so that it has a
I'm trying to modify this example http://storelocator.googlecode.com/git/examples/panel.html the javascript code is here: https://gist.github.com/2725336 the
I am looking to modify this php code to do a recursive search for
How would I modify this code to show the animated movement (item moving from

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.