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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:05:03+00:00 2026-06-08T22:05:03+00:00

I have a ListView which displays a list of items. When I click on

  • 0

I have a ListView which displays a list of items. When I click on an item, I mark the item as striked in my database table. Then, I update the list using a SimpleCursorAdapter, setViewBinder, setViewValue.

I check if the striked column is set for a corresponding item, and then I update the TextView to strike the item.

The code is below

Cursor c = db.fetchAllNotes(id);
    startManagingCursor(c);

    String[] from = new String[] { DatabaseHandler.KEY_LIST };
    int[] to = new int[] { R.id.text1 };

    SimpleCursorAdapter notes =
        new SimpleCursorAdapter(this, R.layout.task_row, c, from, to);

    notes.setViewBinder(new SimpleCursorAdapter.ViewBinder() {

        public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
            // TODO Auto-generated method stub      
            text = (TextView) view.findViewById (R.id.text1);
            System.out.println("Item is "+ text.getText().toString());
            System.out.println("Item from cursor is " + cursor.getString(2));
            System.out.println("Striked value is " + Integer.parseInt(cursor.getString(3)));
            if(Integer.parseInt(cursor.getString(3)) == 1)
                text.setPaintFlags(textViewItem.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            return false;
        }
    });
    setListAdapter(notes);

What am I doing wrong?

  • 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-08T22:05:07+00:00Added an answer on June 8, 2026 at 10:05 pm

    I think it’s because views are reused in ListView. Try to reset paint flags when view is not striked:

     if(Integer.parseInt(cursor.getString(3)) == 1){
         textViewItem.setPaintFlags(textViewItem.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
     } else {
         //resed paint flags
         textViewItem.setPaintFlags(textViewItem.getPaintFlags() & (~ Paint.STRIKE_THRU_TEXT_FLAG));
     }
    

    Edit:
    I am not sure if my explatation is corect. When You have 10 items on ListView and only 5 of them are visible android creates(inflantes) only 5 views. When you scroll list one new item will be visible but olso one will disapear so there will be one unused view. Android wil take that unused view, fill it with new data and use it for newly appeared item. I found some more info here.

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

Sidebar

Related Questions

I have a listview which displays items retrieved from the webpage. Each item in
I have a ListView, which displays a list of notes taken from a table
I have one function which is called on list item Click and list items
I have a list view item which has a button and displays properties on
I have a ListView which displays a list of string values. I want to
I have a ListView-like control that displays a list of items of various heights.
i have an application where it displays a list of items in ListView .
I have a ListView which is using a GridView to display a DataTable and
I have ListView which is saving all data to database. For adding i have
I have a ListView which might contains a lot of items, so it is

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.