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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:42:53+00:00 2026-06-06T06:42:53+00:00

I have extended SimpleCursorAdapter and am running into a weird issue with bindView, which

  • 0

I have extended SimpleCursorAdapter and am running into a weird issue with bindView, which appears to be called twice on the first row.

Only the first row appears to be duplicated. I have a feeling it has something to do with the way the cursor is positioned, but have looked through all the adapter classes and can’t seem to locate where this occurs.

Here is my code for bindView, I have inserted some Logs to show what I’m seeing.

@Override
public void bindView(View view, Context context, Cursor cursor) {
    final ViewBinder binder = getViewBinder();
    final int count = mTo.length;
    final int[] from = mFrom;
    final int[] to = mTo;

    Log.v("builder", "cursor count"+cursor.getCount() );

    Log.v("builder", "mTo.length"+count);
    //Bind all Views
    for (int i = 0; i < count; i++) {
        final View v = view.findViewById(to[i]);
        if (v != null) {
            boolean bound = false;
            if (binder != null) {
                bound = binder.setViewValue(v, cursor, from[i]);
            }

            if (!bound) {
                String text = cursor.getString(from[i]);
                v.setVisibility(View.VISIBLE);
                if (text == null && !(v instanceof ImageView)) {
                    text = "";
                    v.setVisibility(View.GONE);
                } 

                if (v instanceof TextView) {
                    setViewText((TextView) v, text);
                    if (v instanceof EditText){
                        EditText et = (EditText) v;
                        Log.v("builder", "setting up edittext"+cursor.getPosition()+i);
                    //  setUpEditors(view, et);
                    }
                } else if (v instanceof ImageView) {
                    setViewImage((ImageView) v, text);
                } else {
                    throw new IllegalStateException(v.getClass().getName() + " is not a " +
                            " view that can be bound by this SimpleCursorAdapter");
                }


            }
        }
    }


}

Here is my output with only one item in the cursor

06-22 15:15:03.797: V/builder(27573): cursor count1
06-22 15:15:03.797: V/builder(27573): mTo.length5
06-22 15:15:03.807: V/builder(27573): setting up edittext02
06-22 15:15:03.807: V/builder(27573): setting up edittext03
06-22 15:15:03.807: V/builder(27573): setting up edittext04
06-22 15:15:03.887: V/builder(27573): cursor count1
06-22 15:15:03.887: V/builder(27573): mTo.length5
06-22 15:15:03.897: V/builder(27573): setting up edittext02
06-22 15:15:03.897: V/builder(27573): setting up edittext03
06-22 15:15:03.907: V/builder(27573): setting up edittext04

Here it is with 2 items

06-22 15:17:28.337: V/builder(27573): cursor count2
06-22 15:17:28.337: V/builder(27573): mTo.length5
06-22 15:17:28.337: V/builder(27573): setting up edittext02
06-22 15:17:28.337: V/builder(27573): setting up edittext03
06-22 15:17:28.337: V/builder(27573): setting up edittext04
06-22 15:17:28.417: V/builder(27573): cursor count2
06-22 15:17:28.417: V/builder(27573): mTo.length5
06-22 15:17:28.417: V/builder(27573): setting up edittext02
06-22 15:17:28.427: V/builder(27573): setting up edittext03
06-22 15:17:28.427: V/builder(27573): setting up edittext04
06-22 15:17:28.517: V/builder(27573): cursor count2
06-22 15:17:28.517: V/builder(27573): mTo.length5
06-22 15:17:28.527: V/builder(27573): setting up edittext12
06-22 15:17:28.527: V/builder(27573): setting up edittext13
06-22 15:17:28.527: V/builder(27573): setting up edittext14

Here’s the xml where the ListView is located

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" android:orientation="vertical">

<TextView
    android:id="@+id/textView6"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/labels_background"
    android:text="@string/lb_item_type"
    android:textSize="@dimen/dm_maint_tv" />

<CheckBox
    android:id="@+id/mt_base"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/lb_base" />

<TextView
    android:id="@+id/textView10"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:background="@color/labels_background"
    android:text="@string/lb_build"
    android:textSize="@dimen/dm_maint_tv" />

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp" android:layout_weight="1" android:id="@+id/builder">

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

    <ImageView
        android:id="@+id/mt_additem"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="3dp"
        android:layout_marginTop="3dp"
        android:scaleType="centerInside"
        android:src="@drawable/ic_input_add" android:layout_gravity="top|right"/>

</FrameLayout>

  • 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-06T06:42:55+00:00Added an answer on June 6, 2026 at 6:42 am

    If you see the sequence newView/bindView called twice per item, you are probably using ListView with its height set to wrap_content, which is always a bad idea. Can you confirm that you are not doing this?

    Also, I can’t say for sure but this might be perfectly valid behavior, if your first list item is being called twice I mean. It sounds like Android must measure the first list item (which requires the system to call bindView one time) and then populate the list item (also by calling bindView. After the first row is populated (which requires two calls to bindView), the width of each subsequent list item is known and requires only one call to bindView per each item. Let me know if that makes sense…

    Either way, I hope this isn’t something you are worried about… one additional call to bindView won’t kill your app. 🙂

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

Sidebar

Related Questions

I have a class named CropImageView which is extended from ImageView . but the
I have extended my class with a dialog in which I have set content
I have extended Django's User Model using a custom user profile called UserExtension .
I have a list Activity 4 which i have extended the BaseAdapter and the
I have extended the ImageView class in a class called DialButton2 (dont worry about
I have a custom adapter extended from the SimpleCursorAdapter. Using this I'm binding a
I have extended PHP's mysqli class, which works fine. But how can I make
I have a windows form application, and I have extended the window's frame into
I have extended the GLSurfaceView and implemented my own GLSurfaceView.Renderer to create my first
I have extended my entities to implement specific interfaces for its type. I am

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.