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

  • Home
  • SEARCH
  • 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 8857343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:33:59+00:00 2026-06-14T14:33:59+00:00

I have some custom listview adapter, in adapter I use ViewHolder pattern,it is work

  • 0

I have some custom listview adapter, in adapter I use ViewHolder pattern,it is work correctly for anything but not for Bitmaps.

That code is work but plase that work with bitmap don’t use viewholder. I commented it for test, so now I see that, viewholder not work with bitmaps.

If someone know why or have any idea please told me how to fix.

There is my code:

public class FrontListAdapter extends ArrayAdapter<GoodObject> {

    private Context context;
    private AdapterLoadNotifier notifier;
    private List<GoodObject> list;
    public HashMap<String, Bitmap> avatars = new HashMap<String, Bitmap>();

    public FrontListAdapter(MainActivity activity, List<GoodObject> objects) {
        super(activity, R.layout.row_front_layout, objects);
        this.context = activity;
        this.list = objects;
        this.notifier = activity;
    }

    static class ViewHolder {
        static TextView shopTitle;
        static TextView time;
        static TextView description;
        static ImageView goodsImage;
        static ProgressBar loadingGoodsImageDialogue;
        static ImageView shopAvatar;
        static ImageView loadingAvatarHolder;
        static ProgressBar loadingAvatarDialogue;
        static TextView commentAuthor;
        static TextView commentText;
        static Button likeButton;
        static Button commentButton;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(context);
            convertView = inflater.inflate(R.layout.row_front_layout, null);

            viewHolder = new ViewHolder();
            viewHolder.shopTitle = (TextView) convertView.findViewById(R.id.row_front_layout_shop_title);
            viewHolder.time = (TextView) convertView.findViewById(R.id.row_front_layout_time);
            viewHolder.description= (TextView) convertView.findViewById(R.id.row_front_layout_description_label);
            viewHolder.goodsImage = (ImageView) convertView.findViewById(R.id.row_front_layout_good_image);
            viewHolder.loadingGoodsImageDialogue = (ProgressBar) convertView.findViewById(R.id.row_front_layout_good_image_progress);
            viewHolder.shopAvatar = (ImageView) convertView.findViewById(R.id.row_front_layout_logo);
            viewHolder.loadingAvatarDialogue = (ProgressBar) convertView.findViewById(R.id.row_front_layout_avatar_image_progress);
            viewHolder.loadingAvatarHolder = (ImageView) convertView.findViewById(R.id.row_front_layout_logo_back);
            viewHolder.commentAuthor = (TextView) convertView.findViewById(R.id.row_front_layout_first_comment_author);
            viewHolder.commentText = (TextView) convertView.findViewById(R.id.row_front_layout_first_comment_text);
            viewHolder.likeButton = (Button) convertView.findViewById(R.id.row_front_layout_like_button);
            viewHolder.commentButton = (Button) convertView.findViewById(R.id.row_front_layout_comment_button);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        GoodObject goodObject = list.get(position);
        String shopTitle = goodObject.getShopTitle();
        Bitmap avatar = goodObject.getAvatar();
        Bitmap image = goodObject.getGoods_logo();

        viewHolder.shopTitle.setText(shopTitle);
        viewHolder.time.setText(goodObject.getTime());
        viewHolder.description.setText(goodObject.getDescription());

        if (image != null) {
            //viewHolder.goodsImage.setImageBitmap(image);
            //viewHolder.loadingGoodsImageDialogue.setVisibility(View.GONE);
            ((ImageView) convertView.findViewById(R.id.row_front_layout_good_image)).setImageBitmap(image);
            convertView.findViewById(R.id.row_front_layout_good_image_progress).setVisibility(View.GONE);
        }
        if (avatar != null) {
            convertView.findViewById(R.id.row_front_layout_avatar_image_progress).setVisibility(View.GONE);
            convertView.findViewById(R.id.row_front_layout_logo_back).setVisibility(View.GONE);

            //viewHolder.loadingAvatarDialogue.setVisibility(View.GONE);
            //viewHolder.loadingAvatarHolder.setVisibility(View.GONE);
        }
        ((ImageView) convertView.findViewById(R.id.row_front_layout_logo)).setImageBitmap(avatars.get(shopTitle));

        //viewHolder.shopAvatar.setImageBitmap(avatars.get(shopTitle));

        viewHolder.commentAuthor.setText(goodObject.getLast_comment().getUser() + ":");
        viewHolder.commentText.setText(goodObject.getLast_comment().getComment());
        viewHolder.likeButton.setText(Integer.toString(goodObject.getLikesAmount()));
        viewHolder.commentButton.setText(Integer.toString(goodObject.getCommentsAmount()));

        if (position == list.size() - 2 && !notifier.isEnded()) {
            notifier.loadNextPage();
        }
        return convertView;
    }
}
  • 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-14T14:34:01+00:00Added an answer on June 14, 2026 at 2:34 pm

    For fix bug the fields in the ViewHolder class musn’t be static:

    static class ViewHolder {
        TextView shopTitle;
        TextView time;
        TextView description;
        ImageView goodsImage;
        ProgressBar loadingGoodsImageDialogue;
        ImageView shopAvatar;
        ImageView loadingAvatarHolder;
        ProgressBar loadingAvatarDialogue;
        TextView commentAuthor;
        TextView commentText;
        Button likeButton;
        Button commentButton;
    }
    

    In that case all work great and correctly.

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

Sidebar

Related Questions

I have a ListView with a custom list adapter (that extends BaseAdapter). My list
I have some problems with my custom adapter for a ListView . I'm unsure
I have a listview with custom adapter and some elements inside. Then I added
I have a button that should sort a ListView using a custom adapter. The
I have a ListView with a custom Adapter that creates rows containing TextViews that
I have some custom logic that needs to be executed every single time a
I have some existing custom Excel workbooks/applications with code-behind C#, which work fine. They
I have authored some custom classes that I would like to create using XAML:
I have a listview with custom array adapter, the view allows the user to
I have a ListView with a custom view rendered by an adapter. It contains

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.