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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:17:32+00:00 2026-05-30T07:17:32+00:00

I have a ListView that’s populated from a SimpleCursorAdapter each row containing 3 different

  • 0

I have a ListView that’s populated from a SimpleCursorAdapter each row containing 3 different TextViews. I only want to modify one of the TextViews for all rows with a ViewBinder (R.id.text65), however it keeps updating all 3 TextViews of every row. Here’s my code:

cursorAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
        public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
            sign = (TextView) view;
            SharedPreferences currency = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
            String currency1 = currency.getString("Currency", "$");
                    sign.setText(currency1);

                    return true;
        }
    });

P.S. I tried (TextView) findViewById(R.id.text65); and I got a Force close.

  • 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-30T07:17:33+00:00Added an answer on May 30, 2026 at 7:17 am

    Solution 1:

    You should check the column index in the viewbinder:

           public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
               if (columnIndex == cursor.getColumnIndexOrThrow(**??**)) // 0 , 1 , 2 ?? 
                {
                   sign = (TextView) view;
                   SharedPreferences currency = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
                    String currency1 = currency.getString("Currency", "$");
                        sign.setText(currency1);
    
                        return true;
                 }
                 return false;
            }
    

    Note, the column index, is the DBcolumn index of the currency / the index of the column in whatever is your data source.

    Solution 2:

    You are probably defining an int[] for the fields to bind to in your listview for example :

                // and an array of the fields we want to bind those fields to
        int[] to = new int[] { R.id.field1, R.id.field2, R.id.Currency };
    
        SimpleCursorAdapter entries = new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);
    

    … Conditionally, you can simply pass 0 instead of the layout ids of the fields that you donT want to be bound / shown.

                int[] to = new int[] { 0, 0, R.id.Currency };
    

    This way only the Currency field will be bound.


    Also, the reason you get the force close is because, technically, there is no single text65 in your contentView but many. You cannot access it from the main layout level. It is unique only in the scope of a single row.


    Update :

    Solution 3:

    Check the id of the view in the ViewBinder

        public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
            int viewId = view.getId();
            Log.v("ViewBinder", "columnIndex=" + columnIndex + " viewId = " + viewId);
            if(viewId == R.id.text65)
            {
                sign = (TextView) view;
                SharedPreferences currency = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
                String currency1 = currency.getString("Currency", "$");
                sign.setText(currency1);
    
                return true;
             }
             return false;
         }
    

    Could you try this?

    Useful hint: you can use the Log.v to check certain values in your code without having to debug it.

    Hope it helps.

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

Sidebar

Related Questions

I have a listview that contains values from webservice.Each page contains only 10 listitems
I have a ListView that uses SimpleAdapter, each row has 2 TextViews, and I
I have a ListView that is populated using an XML file. However, I want
I have a listview that's populated by rows that get their data from a
I have a ListView that contains 3 checkboxes per row. I want to set
I have a ListView that inflate for each row a xml that contain a
I have a ListView that each row has a title on the left side
I have a ListView that is populated with rows. These rows come from an
I have a listview that is populated by a by objects from an Offer
I have a listview that has a photograph from the gallery for each entry

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.