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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:01:10+00:00 2026-06-03T13:01:10+00:00

Auxiliary Problem Hi, could anyone please help me understand the behavior of SimpleCursorAdapter.ViewBinder.setViewValue ?

  • 0

Auxiliary Problem

Hi, could anyone please help me understand the behavior of SimpleCursorAdapter.ViewBinder.setViewValue?

It seems that it is called more than once for each row in the ListView. Does the number of calls depend on the number of rows in the ListView? Or number of items in the cursor of SimpleCursorAdapter? Also, what are the significance of the parameters passed to the function?

Main Problem

I’m having this strange problem while trying to create a simple ListView of CheckedTextViews. I wanted to reduce the opacity of the rows which are checked. The code I wrote worked, except that it will always reduce the opacity of one extra row.

Making the layout_height of the ListView to match_parent solved the issue for some cases. But the problem still persists when I open the keyboard for editing and the ListView somehow gets required.


Please find the codes here

Code to fill the items in ListActivity:

private void fillDataToList() {
    Cursor all_taskCursorCursor = mDbHelper.fetchAllTask();
    startManagingCursor(all_taskCursorCursor);

    String[] from = new String[]{TaskDbAdapter.KEY_TITLE};
    int[] to = new int[]{R.id.task_title};

    SimpleCursorAdapter tasks = new SimpleCursorAdapter(this, R.layout.task_row, all_taskCursorCursor, from, to);

    tasks.setViewBinder(new ViewBinder() {

        public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
            if(columnIndex == 1) {
                CheckedTextView ctv = (CheckedTextView) view;

                String text = cursor.getString(cursor.getColumnIndexOrThrow(TaskDbAdapter.KEY_TITLE));
                boolean checked = cursor.getInt(cursor.getColumnIndexOrThrow(TaskDbAdapter.KEY_COMPLETED)) == 1 ? true : false; 

                ctv.setText(text);
                ctv.setChecked(checked); 

                if (checked == true) {
                    AlphaAnimation animation = new AlphaAnimation(1, 0.25f);
                    animation.setFillAfter(true);
                    ctv.setAnimation(animation); 

                    ctv.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
                }

                return true;
            }

            return false;
        }
    });

    setListAdapter(tasks);
}

The layout of ListView –

<?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="fill_parent"
android:orientation="vertical" >

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</ListView>

<TextView
    android:id="@android:id/empty"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="@string/no_task"
    android:padding="10dp"
    android:gravity="center_vertical|center_horizontal"
    android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>

Layout for each row –

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

<CheckedTextView
    android:id="@+id/task_title"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:padding="10dp"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:checkMark="?android:attr/listChoiceIndicatorMultiple" />

</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-03T13:01:12+00:00Added an answer on June 3, 2026 at 1:01 pm

    The problem was solved by adding one else condition to if (checked == true) part.

    The final code looks like this –

    if (checked == true) {
        AlphaAnimation animation = new AlphaAnimation(1, 0.25f);
        animation.setFillAfter(true);
        ctv.setAnimation(animation); 
    
        ctv.setPaintFlags(ctv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
    } else {
        ctv.setPaintFlags(ctv.getPaintFlags() & (~ Paint.STRIKE_THRU_TEXT_FLAG));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if anyone could help me with this problem: I have to
My problem : I got a MySQL database that stores a great amount of
I have a model that requires loading external data from an auxiliary source. A
I wonder if anyone could offer their advice on this one. I have some
I've got bunches of auxiliary files that are generated by code and LaTeX documents
I have a problem that I would like to tell you because is about
I wrote an __init__ method for one of my models that adds some auxiliary
I have some code that displays a checkmark as the auxiliary view of a
Below is my code: #include <stdio.h> #include <string.h> #include <curl/curl.h> /* Auxiliary function that
I have the following problem (I think it's well known/standard) that I am thinking

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.