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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:42:27+00:00 2026-05-29T07:42:27+00:00

i’m building small sms-like application. I made conversation list view, but there is a

  • 0

i’m building small sms-like application. I made conversation list view, but there is a problem. Every row in the list has photo (contact photo) and if i scroll down some rows have photos from different rows (from the beggining of the list).

Here’s my adapter:

import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

public class ConversationAdapter extends SimpleCursorAdapter {
    private final String TAG = "ConversationAdapter";
    static final String[] FROM = {"body", "address", "date", "m_size"};
    static final int[] TO = {R.id.textMsg, R.id.textPerson, R.id.textDate, R.id.textConvCounter};
    ImageView imageAvatar;
    ContentResolver contentResolver;
    LayoutInflater layoutInflater;

    public ConversationAdapter(Context context, Cursor c) {
        super(context, R.layout.row, c, FROM, TO);
    }
    @Override
    public void bindView(View row, Context context, Cursor cursor) {
        super.bindView(row, context, cursor);

        long timestamp = cursor.getLong(cursor.getColumnIndex("date"));
        TextView textDate = (TextView) row.findViewById(R.id.textDate);
        textDate.setText(DateUtils.getRelativeTimeSpanString(timestamp));
        TextView textMsg = (TextView) row.findViewById(R.id.textMsg);

        String previewMsg = cursor.getString(cursor.getColumnIndex("body"));
        if (previewMsg.length() > 40)
        {
            textMsg.setText(previewMsg.substring(0, 37) + "...");
        }

        TextView textPerson = (TextView) row.findViewById(R.id.textPerson);
        String contactId = DataManager.getContactId(context, (textPerson.getText()).toString());
        if (contactId != "")
        {
            contentResolver = context.getContentResolver();
            imageAvatar = (ImageView) row.findViewById(R.id.imageAvatar);
            Long lContactId = Long.parseLong(contactId);
            Bitmap bitmap = DataManager.getContactPhoto(contentResolver, lContactId);
            if (bitmap != null)
            {
                imageAvatar.setImageBitmap(bitmap);
                bitmap = null;
            }
            String contactName = DataManager.getContactName(context, (textPerson.getText()).toString());
            textPerson.setText(contactName);
        }
    }

}

and there is my activity that shows the list:

import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class ConversationsActivity extends Activity {
    private final String TAG = "ConversationsActivity";
    ConversationAdapter adapter;
    ContentResolver contentResolver;
    Cursor cursor;
    ListView convList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.conversations_list);
        convList = (ListView) findViewById(R.id.convList);

    }

    @Override
    protected void onResume() {
        super.onResume();
        setupConvsList();
    }
    void setupConvsList()
    {
        Context context = getApplicationContext();
        contentResolver = context.getContentResolver();
        cursor = contentResolver.query(Uri.parse("content://mms-sms/conversations"), null, null, null, "date DESC");
        startManagingCursor(cursor);

        adapter = new ConversationAdapter(this, cursor);
        convList.setAdapter(adapter);
    }
}

What do i have to change?
Thanks!

  • 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-29T07:42:28+00:00Added an answer on May 29, 2026 at 7:42 am

    The problem is here :

    if (contactId != "")
            {
                contentResolver = context.getContentResolver();
                imageAvatar = (ImageView) row.findViewById(R.id.imageAvatar);
                Long lContactId = Long.parseLong(contactId);
                Bitmap bitmap = DataManager.getContactPhoto(contentResolver, lContactId);
                if (bitmap != null)
                {
                    imageAvatar.setImageBitmap(bitmap);
                    bitmap = null;
                }
                String contactName = DataManager.getContactName(context, (textPerson.getText()).toString());
                textPerson.setText(contactName);
            }
    

    You have to make an else statement too and set a default image or something there.. else your reusable View will remain with the old image that you set previously.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words

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.