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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:49:19+00:00 2026-06-16T19:49:19+00:00

I am not clear whether this is an issue with different versions of Android,

  • 0

I am not clear whether this is an issue with different versions of Android, or different screen sizes, but I am getting some unpredictable behavior.

I am testing the UI of the dropdown of a MultiAutoCompleteTextView on a Nexus S which is on Android v4.1.2 and I am testing on a Nexus 4 which is on Android v4.2.1.

When I begin to enter text into the MultiAutoCompleteTextView it returns some results. I have created a custom view which contains an ImageView to the left of a TextView. When the a row is first displayed, the ImageView will have a certain height and width (image on left).


However once you scroll through the list of results and back up to that original row one, of two things happens. Either the ImageView stays the same dimensions, or the dimensions of the ImageView will change (image on right).

This specific behavior, and the screenshots provided, are what is happening on the Nexus 4, but I cannot reproduce this issue on the Nexus S.

I am loading Bitmaps into ImageViews just like it is done in the developer training Loading Large Bitmaps Efficiently.

Here is the layout resource for the contact row:

contact_entry2.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/contactPic"
        android:layout_width="wrap_content"
        vandroid:layout_height="fill_parent"
        android:contentDescription="@string/contact_pic_desc"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:src="@drawable/ic_contact_picture" />

    <CheckedTextView
        android:id="@+id/contactInfo"
        style="@style/CheckedTextViewStyle" >
    </CheckedTextView>

</LinearLayout>

styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="CheckedTextViewStyle">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">match_parent</item>
        <item name="android:textColor">@color/black</item>
        <item name="android:background">@color/white</item>
        <item name="android:gravity">center_vertical</item>
        <item name="android:paddingLeft">10dp</item>
    </style>

</resources>

And RecipientsCursorAdapter is a grandchild class of the SimpleCursorAdapter (BaseContactsAdapter extends SimpleCursorAdapter):

RecipientsCursorAdapter

package com.sendit.adapters;

import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.provider.ContactsContract;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckedTextView;
import android.widget.ImageView;

import com.sendit.Contact;
import com.sendit.R;
import com.sendit.util.ContactsUtils;
import com.sendit.util.ImageFetcher;

public class RecipientsCursorAdapter extends BaseContactsAdapter {

    private final String DEBUG_TAG = getClass().getSimpleName().toString();
    private Cursor mCursor;
    private ImageFetcher mImageFetcher;

    public RecipientsCursorAdapter(Context context, int layout, Cursor c,
        String[] from, int[] to, Activity a, int flags, ImageFetcher imageFetcher) {
            super(context, layout, c, from, to, a, flags);
            mImageFetcher = imageFetcher;
    }

    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.contact_entry2, null);
            // Creates a ViewHolder and store references to the children views
            // we want to bind data to.
            holder = new ViewHolder();
            holder.contactInfo = (CheckedTextView) convertView
                .findViewById(R.id.contactInfo);
            holder.contactPic = (ImageView) convertView
                .findViewById(R.id.contactPic);

            convertView.setTag(holder);

        } else {
            // Get the ViewHolder back to get fast access to the TextView
            // and the ImageView.
            holder = (ViewHolder) convertView.getTag();
        }

        holder.position = position;

        mCursor = getCursor();

        mCursor.moveToPosition(position);

        int contactId = mCursor.getInt(mCursor
            .getColumnIndex(ContactsContract.Contacts._ID));

        if (mContactCache.get(contactId) == null) {
            String name = mCursor.getString(mCursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
            String number = ContactsUtils.getPhoneNumber(mContext, contactId);
            mContactCache.put(contactId, new Contact(name, number));
        }

        Contact c = mContactCache.get(contactId);

        CharSequence contactInfo = getContactInfoSpan(c.getName(), c.getPhoneNumber());

        holder.contactInfo.setText(contactInfo);

        mImageFetcher.loadImage(contactId, holder.contactPic);

        return convertView;
    }

}

Can anyone point me in the right direction as far as what to look into? Is this a screen resolution issue, or does the latest version of Android handle this situation differently than previous versions?

  • 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-16T19:49:20+00:00Added an answer on June 16, 2026 at 7:49 pm

    Thanks @Andrew for the suggestions. Here’s how I fixed the image resizing issue. I called the ImageView setScaleType() and setLayoutParams() methods when instantiating the ViewHolder references.

    public class RecipientsCursorAdapter extends BaseContactsAdapter {
    
        private final String DEBUG_TAG = getClass().getSimpleName().toString();
        private Cursor mCursor;
        private ImageFetcher mImageFetcher;
        private final Drawable mDefaultContactPic;
        private LinearLayout.LayoutParams mImageViewLayoutParams;
    
        public RecipientsCursorAdapter(Context context, int layout, Cursor c,
            String[] from, int[] to, Activity a, int flags, ImageFetcher imageFetcher) {
    
            super(context, layout, c, from, to, a, flags);
            mImageFetcher = imageFetcher;
            mDefaultContactPic = context.getResources().getDrawable(R.drawable.ic_contact_picture);
            mImageViewLayoutParams = new LinearLayout.LayoutParams(mDefaultContactPic.getIntrinsicWidth(), mDefaultContactPic.getIntrinsicHeight());
        }
    
        public View getView(final int position, View convertView, ViewGroup parent) {
            ViewHolder holder;
            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.contact_entry2, null);
                // Creates a ViewHolder and store references to the children views
                // we want to bind data to.
                holder = new ViewHolder();
                holder.contactInfo = (CheckedTextView) convertView.findViewById(R.id.contactInfo);
                holder.contactPic = (ImageView) convertView.findViewById(R.id.contactPic);
    
                holder.contactPic.setScaleType(ImageView.ScaleType.CENTER_CROP);
                holder.contactPic.setLayoutParams(mImageViewLayoutParams);
    
                convertView.setTag(holder);
    
            } else {
                // Get the ViewHolder back to get fast access to the TextView
                // and the ImageView.
                holder = (ViewHolder) convertView.getTag();
            }
    
            holder.position = position;
    
            mCursor = getCursor();
    
            mCursor.moveToPosition(position);
    
            int contactId = mCursor.getInt(mCursor.getColumnIndex(ContactsContract.Contacts._ID));
    
            /*...*/
    
            mImageFetcher.loadImage(contactId, holder.contactPic);
    
            return convertView;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's not clear to me why I'm getting this particular exception, it's a red-herring
Not clear on some fundamental syntax here. define-key accepts a set of inputs, one
I am playing with Autolayout in Cocoa and some things are not clear for
**Okay, It's become clear that this issue is an issue related with the setup
This has already been asked Here , but not by me and the OP
It's not clear, to me anyway, if a UIView is automatically released from its
It's not clear to me if the Eclipse plugin completely replaces the need to
I am not clear on the actual difference between these two styles of class
I'm not clear on the status of XHTML - v1.0 versus v1.1. Can someone
I am not clear from the documentation - when I indicate a cell width

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.