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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:55:29+00:00 2026-05-29T08:55:29+00:00

I have this particular problem which follows me since couple days. I used the

  • 0

I have this particular problem which follows me since couple days. I used the search but couldn’t found any article witch would be helpful for my problem yet. i guess it also a problem of my search.
however, back to my question.

I use a ResourceCursorAdapter to fill my ListView.
My ListView Item looks like..

    <?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" >

        <TextView
            android:id="@+id/title_tv"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <TextView
            android:id="@+id/description_tv"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <CheckBox
            android:id="@+id/download_cb"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <Button
            android:id="@+id/some_bt"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <ImageButton
            android:id="@+id/pdf_ib"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <ProgressBar
            android:id="@+id/download_pb"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="fill_parent"
            android:layout_height="10dip" />
    </RelativeLayout>       

My Adapter:

private final class ListAdapter extends ResourceCursorAdapter implements
        DownloadCallback, OnItemClickListener, OnClickListener {

            public ListAdapter(Context context, int layout, Cursor c) {
        super(context, layout, c);
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        final ItemHolder holder = (ItemHolder) view.getTag();

        holder.url = cursor.getString(..);

        holder.titleTv.setText(cursor.getString(..));
        holder.descriptionTv.setText(cursor.getString(..));
        ...

        if(cursor.getInt(..) == 1) {
            holder.progress.setVisible(View.GONE);          
        }

        if(cursor.getInt(...) == 1) {
            holder.downloadCb.setEnabled(isConnectedToNet); 
        }
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        View view = super.newView(context, cursor, parent);
        ItemHolder holder = new ItemHolder();

        view.setOnClickListener(this);

        holder.titleTv = (TextView) view.findViewById(R.id.title_tv);
        holder.descriptionTv = (TextView) view.findViewById(R.id.description_tv);
        ...

        holder.downloadCb.setEnabled(isConnectedToNet);                 
        holder.downloadCb.setOnClickListener(this);         
        holder.downloadCb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {                    
                prepare2Download();

                DownItem di = new DownItem();
                di.url = holder.url;        /// <========= to do this               

                // start async downloader and notify progressbar "holder.downPb"                    
                Download serverTaskObject = new Download();                 
                serverTaskObject.execute(currDownholder.copy());    

                holder.downPb.setVisibility(View.GONE);     // <======== and this.          
            }
        });

        holder.pdfIb = (ImageButton) view.findViewById(R.id.pdf_ib);
        holder.pdfIb.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // start new activity and load website.
                openUrl(holder.url);    // <============ or this.
            }
        });

        holder.downPb = (ProgressBar) view.findViewById(R.id.pb_law_download);
        holder.downPb.setVisibility(View.GONE);

        view.setTag(cachedItem);
        return view;
    }

    ...

    private static class LawItemCache {
        TextView titleTv;
        TextView descriptionTv;
        ...

        CheckBox downloadCb;
        ImageButton pdfIb;

        ProgressBar downPb;

        String url;
        IProgressListener listener;
    }
}

My question is..
When i click on a Button or a Checkbox in the ListView i want to make some changes in the specific View holder, like to make the Progressbar visible or gone.
I couldn’t figure out yet how i get the View holder within my adapter to make my changes.

I hope i explained it well enough to get into the point of my 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-29T08:55:30+00:00Added an answer on May 29, 2026 at 8:55 am

    I struggled with this a lot and finally managed to get it working! I have a checkbox in my Row and an using a ResourceCursorAdapter. The trick was to realize that the checkbox clicked handler needs to be bound either in getView() or newView() while the holder needs to be associated in bindView(). That way the currently displayed rows in the ListView always have the correct holder info. Here are my bindView and getView methods:

     public void bindView(View view, Context context, Cursor cursor) {
                    Log.i(CN,"bindView");
                    TextView todoTxt = (TextView)view.findViewById(R.id.todoItemText);
                    Log.i(CN,"bindView set txt");
                    TextView todoTitle = (TextView)view.findViewById(R.id.todoItemTitle);
                    Log.i(CN,"bindView set title");
                    CheckBox cBox = (CheckBox)view.findViewById(R.id.todoChecked);
                    Log.i(CN,"bindView set check");
    
                    IOweRowTag tag=(IOweRowTag)cBox.getTag();
                    int pos=cursor.getInt(cursor.getColumnIndex(Todos._ID));
                    Log.i(CN,"getView: no tag on "+pos);
                    tag=new IOweRowTag();
                    tag.id=pos;
                    cBox.setTag(tag);
    
    //              IOweRowTag irt=(IOweRowTag)view.getTag();
    //              if(irt!=null)
    //                  Log.i(CN,"Got irt id="+irt.id);
    //              else
    //                  Log.i(CN,"No id");
    //              
                    Log.i(CN,"got title="+cursor.getString(cursor.getColumnIndex(Todos.TITLE)));
                    Log.i(CN,"got txt="+cursor.getString(cursor.getColumnIndex(Todos.TEXT)));
    
                    todoTitle.setText(cursor.getString(cursor.getColumnIndex(Todos.TITLE)));
                    todoTxt.setText(cursor.getString(cursor.getColumnIndex(Todos.TEXT)));
                    cBox.setChecked(true);
    
                }
    
    
    
    
            public View getView (int position, View convertView, ViewGroup parent) {
                View tmpView=super.getView(position, convertView, parent);
                Log.i(CN,"getView:"+position);
                final CheckBox cBox = (CheckBox) tmpView.findViewById(R.id.todoChecked);
                IOweRowTag tag=(IOweRowTag)cBox.getTag();
                cBox.setOnClickListener(new OnClickListener() { 
    
                    public void onClick(View v) { 
                        IOweRowTag tag=(IOweRowTag)v.getTag();
                        if(tag==null)
                            Log.i(CN,"checkbox clicked no tag");
                        else
                            Log.i(CN,"checkbox clicked tag="+tag.id);
                       if(cBox.isChecked()) { 
                           Log.i(CN," Checked!"); 
                           // do some operations here 
                       }   
                       else{ 
                           Log.i(CN,"NOT Checked!"); 
                           // do some operations here 
                       }
                   }
                    });
    
    
                return tmpView;
            }
    

    Hope this helps you!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this problem to find a particular xml node l have post this
Crappy title, yes. But I honestly have no idea what this particular line of
I have a problem that can be simplified as follows: I have a particular
I am using Struts2 for a web application development. i have this particular problem
In the end, I have decided that this isn't a problem that I particularly
I have an effect that when you hover over this one particular area, it
This is how I have currently managed to consume a particular Microsoft web service.
I have List of particular class. I want to save this List at a
We have written a software package for a particular niche industry. This package has
In a WPF/MVVM application I have a custom control on a particular view. This

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.