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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:03:10+00:00 2026-05-22T22:03:10+00:00

Looks like there are two possible ways to change something in the ListView rows:

  • 0

Looks like there are two possible ways to change something in the ListView rows:

  1. using of setViewBinder/setViewValue:

    myCursor.setViewBinder(new SimpleCursorAdapter.ViewBinder() {

      @Override
      public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
        int viewId = view.getId();
        switch(viewId) {
        case R.id.icon:
            // change something related to the icon here
    
  2. using of getView/LayoutInflater:

    public View getView(int position, View convertView, ViewGroup parent) {

        View itemView = null;
    
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) parent.getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            itemView = inflater.inflate(R.layout.list_row, null);
        } else {
            itemView = convertView;
        }
    
        ImageView imgViewChecked = (ImageView) itemView
                .findViewById(R.id.icon);
        // change something related to the icon here
    

What is the difference between these two approaches?

  • 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-22T22:03:11+00:00Added an answer on May 22, 2026 at 10:03 pm

    You can use both of them to accomplish the same task.
    The ViewBinder system is added by SimpleCursorAdapter to make things easier for you, so you don’t have to write the entire getView code. In fact, SimpleCursorAdapter just implements getView by calling the setViewValue method (along with the standard boilerplate error checking and inflating)

    I’ve attached the implementation that the Android source code uses for getView in SimpleCursorAdapter:

    public View getView(int position, View convertView, ViewGroup parent) {
      if (!mDataValid) {
        throw new IllegalStateException(
            "this should only be called when the cursor is valid");
      }
      if (!mCursor.moveToPosition(position)) {
        throw new IllegalStateException("couldn't move cursor to position "
            + position);
      }
      View v;
      if (convertView == null) {
        v = newView(mContext, mCursor, parent);
      } else {
        v = convertView;
      }
      bindView(v, mContext, mCursor);
      return v;
    }
    
    
    public void bindView(View view, Context context, Cursor cursor) {
      final ViewBinder binder = mViewBinder;
      final int count = mTo.length;
      final int[] from = mFrom;
      final int[] to = mTo;
    
      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]);
            if (text == null) {
              text = "";
            }
    
            if (v instanceof TextView) {
              setViewText((TextView) v, text);
            } else if (v instanceof ImageView) {
              setViewImage((ImageView) v, text);
            } else {
              throw new IllegalStateException(
                  v.getClass().getName()
                      + " is not a "
                      + " view that can be bounds by this SimpleCursorAdapter");
            }
          }
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It looks like there a few working solutions for using custom true type fonts
My XML looks like : <?xml version=\1.0\?> <itemSet> <Item>one</Item> <Item>two</Item> <Item>three</Item> .....maybe more Items
Looks like there is no Load event for usercontrol on the CF. I'm used
It looks like there are a variety of virtual machine offerings available. What is
On the web page, it looks like there is no current development in the
BITS, the Windows background intelligent transfer service. Looks like there are a few C#
I am running into a randomly occuring issue, and it looks like either there
Looks like here in StackOveflow there is a group of F# enthusiasts. I'd like
Is there any themes for emacs which looks like this one? http://www.lnbogen.com/VisualStudioNet2005Colors.aspx
I'm trying to create Excel 2007 Documents programmatically. Now, there are two ways I've

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.