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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:15:40+00:00 2026-06-07T00:15:40+00:00

I have a SimpleCursorAdapter and I’m attempting to bind a SimpleCursorAdapter.ViewBinder to it. Below

  • 0

I have a SimpleCursorAdapter and I’m attempting to bind a SimpleCursorAdapter.ViewBinder to it. Below is the code that I am using.

// Setup Cursor and SimpleCursorAdapter, called in Activity onResume()
Cursor userCursor = getUserProfile(userEmail);
mAdapter = new SimpleCursorAdapter(this, 
                R.layout.user_profile,
                userCursor, 
                new String[] { 
                    StackOverFlow.Users.FULL_NAME,
                    StackOverFlow.Users.EMAIL }, 
                new int[] {
                    R.id.txtvwProfileUserFullName,
                    R.id.txtvwProfileOtherUserInfo } ); 
mAdapter.setViewBinder(new UserProfileViewBinder());

My UserProfileViewBinder class:

private class UserProfileViewBinder implements SimpleCursorAdapter.ViewBinder {
    @Override
    public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
        TextView tv;
        switch (columnIndex) {
        case 1: // TODO: Magic Numbers, bad!
            tv = (TextView) view.findViewById(R.id.txtvwProfileUserFullName);
            String userFullName = cursor.getString(columnIndex);
            tv.setText(userFullName);
            break;
        case 2: // TODO: Magic Numbers, bad!
            tv = (TextView) view.findViewById(R.id.txtvwProfileOtherUserInfo);
            String userEmail = cursor.getString(columnIndex);
            tv.setText(userEmail);
            break;
        }
        return true;

    }
}

Issue

When I load the activity, the TextView’s do not get updated with the data from the userCursor. I can confirm that userCursor is in fact pointing to a valid row in the backing SQLite database, and has data, but the setViewValue method in UserProfileViewBinder never appears to be executing. I’m not sure what I’m doing wrong, or neglecting to include.

As an alternative, I’m doing the following to set the TextView’s text:

if (mAdapter.getCursor().moveToFirst()) {
    mUserFullName.setText(mAdapter.getCursor().getString(
            StackOverFlow.USER_FULL_NAME));
    mUserOtherInfo.setText(mAdapter.getCursor().getString(
            StackOverFlow.USER_EMAIL));
}

But I don’t think this will automatically update the TextView’s when the cursor data changes. when the ContentProvider calls setNotificationUri after executing a query, and the REST server call returns and the thread updates the row the cursor is pointing at.

Thanks in advance.

  • 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-07T00:15:42+00:00Added an answer on June 7, 2026 at 12:15 am

    Are you planing to do other thing besides setting the text on those two TextViews? If the answer is no then you have no reason to use the ViewBinder as the SimpleCursorAdapter, by default, will set the text for you.

    Anyway, I don’t understand why you used the columnIndex parameter to identify the views and not the id of the view that is passed in. See if this helps:

    public boolean setViewValue(View view, Cursor cursor, int columnIndex) {        
            if (view.getId() == R.id.txtvwProfileUserFullName) {
                String userFullName = cursor.getString(columnIndex);
                ((TextView) view).setText(userFullName);
                return true;
            } else if (view.getId() == R.id.txtvwProfileOtherUserInfo) {
                String userEmail = cursor.getString(columnIndex);
                ((TextView) view).setText(userEmail);
                return true;
            } else {
                return false;
            }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity that calls the new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to); setListAdapter(notes);
I have a ListView in my activity that is populated from a database Cursor
I have two other apps that use a ListView and SimpleCursorAdapter . The code
I have a database SQLite and then using SimpleCursorAdapter , I display values into
I have a listview which is populated by a SimpleCursorAdapter that is binding data
I have an Activity (not a ListActivity, although I should probably convert my code
I have a ListView with SimpleCursorAdapter. The layout was using a LinearLayout, but when
I have a ListView and I'm using SimpleCursorAdapter to populate the content, and newView
I have a ListView that's populated from a SimpleCursorAdapter each row containing 3 different
I have used SimpleCursorAdapter for display the data into a list in my activity

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.