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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:30:59+00:00 2026-06-15T06:30:59+00:00

i have the problem about when user click the checkbox inside the listView ,

  • 0

i have the problem about when user click the checkbox inside the listView , the textView will no charge it to Paint.STRIKE_THRU_TEXT_FLAG) . When the user click the checkbox ,the strike line will display in the textView .

           public void bindView(View row, Context context, Cursor c) {
            // TODO Auto-generated method stub

            listName = (TextView) row.findViewById(R.id.produtName);
            listCheck = (CheckBox) row.findViewById(R.id.check);
                            Item tag = (Item) listCheck.getTag();
            String pos = helper.getProductId(c);
            Log.i(CN, "getView: no tag on " + pos);
            tag = new Item();
            tag.id = Integer.parseInt(pos);
            listCheck.setTag(tag);
            listCheck.setChecked(false);
                        String status = helper.getProductStatusT(c);
            if (Integer.parseInt(status) == 0) {
                listCheck.setChecked(true);
                listName.setPaintFlags(listName.getPaintFlags()
                        | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
                listCheck.setChecked(false);
                listName.setPaintFlags(listName.getPaintFlags()
                        & (~Paint.STRIKE_THRU_TEXT_FLAG));
            }


           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.check);
            Item tag = (Item) cBox.getTag();

            cBox.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    Item tag = (Item) v.getTag();
                    if (tag == null)
                        Log.i(CN, "checkbox clicked no tag");

                    else

                        helper.updateStatus(tag.id);

                    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
                        helper.updateStatus2(tag.id);
                    }
                }
            });
            return tmpView;
        }

the checkBox work fine . But the problem is when user click the checkbox , the strike line will not display out . Anyone know where should i put the

listName.setPaintFlags(listName.getPaintFlags()| Paint.STRIKE_THRU_TEXT_FLAG);
  • 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-15T06:31:00+00:00Added an answer on June 15, 2026 at 6:31 am

    I think i might have an idea what you might be trying now, see if the following is working for you:

    public class CustomCursorAdapter extends CursorAdapter {
    
        private LayoutInflater inflator;
        private boolean[] arrCb;
    
        public CustomCursorAdapter(Context context, Cursor c, int flags) {
            super(context, c, flags);
            inflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            arrCb = new boolean[c.getCount()];
            // ^ this will hold the checkbox states
            resetArrcb();
        }
    
        @Override
        public View newView(Context context, Cursor c, ViewGroup parent) {
            View v = inflator.inflate(R.layout.lv_row, parent, false);
            // inflate the xml that the textView and checkbox is in
            return v;
        }
    
        @Override
        public void bindView(View row, Context context, final Cursor cursor) {
            // you do everything else here. there's no need for getView when you use newView and bindView
            final TextView listName = (TextView) row.findViewById(R.id.produtName);
            final CheckBox listCheck = (CheckBox) row.findViewById(R.id.check);
    
            if (arrCb[cursor.getPosition()]) {
                listCheck.setChecked(true);
                listName.setPaintFlags(listName.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            } else {
                listCheck.setChecked(false);
                listName.setPaintFlags(listName.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
            }
    
            listCheck.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    if (listCheck.isChecked()) {
                        arrCb[cursor.getPosition()] = true;
                    } else {
                        arrCb[cursor.getPosition()] = false;
                    }
                    notifyDataSetChanged();
                }
            });
    
        }
    
        private void resetArrcb() {
            // i'm using this to fill the collection but you could easily loop through your 
            // database to fill it with the correct values.
            for (int i = 0; i < arrCb.length; i++) {
                arrCb[i] = false;
            }
        }
    
    }
    

    Then i’m not sure, but it seems like you’d want to adjust your database depending on what is selected. I’d suggest doing it when everything is all over, when your activity is being exited. perhaps set a new method that will just loop through the checkbox collection then do what you intended in the database. it should match 1 to 1 with with table rows.

    EDIT

    Even even better, make a getter method to return your array instead so you can do your database operations right in your activity.

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

Sidebar

Related Questions

I have problem adding arraylist to list view, will explain about my problem here..
I have a problem about casting a CallableStatement to OracleCallableStatement . It gives ClassCastException
I have a problem about div position relative alignment. I want the second div
I am using MFC CFile Seek function. I have a problem about Seek out
I have a little problem about the sort direction of a specific column in
I have a great problem about the rotation in three.js I want to rotate
I have a little problem about Google Maps. I'm using Geocoding (xml) for getting
I have a little problem about using jQuery (I really do not know jQuery
I have got a strange problem about in_array recently which I cannot understand. e.g.
I have got a performance problem about TextField.htmlText +=msg .And I know that TextField.appendText(msg)

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.