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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:32:20+00:00 2026-05-20T22:32:20+00:00

Here’s the ListAdapter that I am trying to bind my ListView with. ListAdapter adapter

  • 0

Here’s the ListAdapter that I am trying to bind my ListView with.

ListAdapter adapter = new SimpleCursorAdapter(this, R.layout.my_item,c,new String[] {"title","body"},
new int[] { R.id.TextView_Title,R.id.TextView_Body});
setListAdapter(adapter);

This works. But I am stuck at what I guess should be very simple. What I want to do is to display the title completely while I display a sub string of the body (say, first 10/15 chars). How do I do this in this case? Can I manipulate the cursor directly in a way so that it returns a substring at the first place or do I have to do it after the cursor has returned the values (in that case, how?). Thanks for the help.

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

    EDIT: OK, sorry I thought you wanted to ‘get’ the substring of the body column but you want to ‘set’ it as a substring???

    Implement SimpleCursorAdapter.ViewBinder on your activity and override setViewValue().

    At some point in your code you’ll need to use…

    adapter.setViewBinder(this); // Put this on onCreate() perhaps
    

    …and the code would look similar to this…

    public class MyActivity extends Activity
        implements SimpleCursorAdapter.ViewBinder {
    
        @Override
        public boolean setViewValue(View view, Cursor cursor, int column) {
            int bodyColumn = cursor.getColumnIndex("body");
            if (column == bodyColumn) {
                String bodyString = cursor.getString(bodyColumn);
                ((TextView)view).setText(bodyString.subString(0, 10));
    
                return true; // Return true to show you've handled this column
            }
            return false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is what I am trying to achieve in PHP: I have this string:
Here is the code in a function I'm trying to revise. This example works
Here is the css: #content ul { font-size: 12px; } I am trying this:
Here is the problem that I am trying to solve. I have two folders
Here's the flow that I am trying to achieve: 1) User uploads an audio
Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario. I'm writing my geo-ruby oracle adapter for Ruby On Rails
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();
Here is the code I'm using inside my AsyncTask DefaultHttpClient httpClient = new DefaultHttpClient();

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.