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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:18:32+00:00 2026-06-10T03:18:32+00:00

public View getView(final int position, View convertView, ViewGroup parent) { SectionHolder sectionHolder = null;

  • 0
public View getView(final int position, View convertView, ViewGroup parent) {
    SectionHolder sectionHolder = null;
    ViewHolder holder = null;
    convertView = listAdapter.getView(getIndexForPosition(position),
                convertView, parent);
    convertView.setTag(contactsIds[getIndexForPosition(position)]);
    holder = new ViewHolder();
    holder.txtTitle = (TextView) convertView
                .findViewById(R.id.list_item_title);
    holder.id = contactsIds[getIndexForPosition(position)];
    new ThumbnailTask(holder,contactsIds[getIndexForPosition(position)]).execute();
    return convertView;
}

private class ThumbnailTask extends AsyncTask<Void, Void, Integer> {
    private String mId;
    private ViewHolder mHolder;
    public ThumbnailTask(ViewHolder holder, String id) {
        mId = id;
        mHolder = holder;
    }

    @Override
    protected Integer doInBackground(Void... params) {
        // TODO Auto-generated method stub
        int drawableId = getContactStatus(mHolder.id);
        // Log.i("DRAWABLE",drawableId+"");
        return drawableId;
    }

    protected void onPostExecute(Integer drawableId) {
        if (mHolder.id.equals(mId)) {
            if (drawableId != 0) {
                if (UpdateStatusService.user == 1) {
                    mHolder.txtTitle.setCompoundDrawablesWithIntrinsicBounds(0, 0,drawableId, 0);
                } else {
                    mHolder.txtTitle.setCompoundDrawablesWithIntrinsicBounds(0, 0,R.drawable.ic_action_quetion, 0);
                }
            } else {
                    mHolder.txtTitle.setCompoundDrawablesWithIntrinsicBounds(0,0, android.R.color.transparent, 0);
            }
        }
    }
}
static class ViewHolder {
    public TextView txtTitle;
    public String id;
}

This is my code of adapter to getView of the listview.

ListView Contains the list of contacts from the android.

but i am getting the java.util.concurrent.RejectedExecutionException
Async task basically get the image from the server and if any number matches to the server data that will contain one image to set otherwise not.

So what should i do to avoid this exception?

  • 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-10T03:18:34+00:00Added an answer on June 10, 2026 at 3:18 am

    AsyncTask threads are placed in a work queue. That work queue restricts how many threads you can instantiate. When you exceed the maximum it will give you a RejectedExecutionException.

    The solution is to refactor your code to not instantiate threads in getView() or have a check that controls if a thread for the current row already has started. getView() gets called very frequently and therefore you will eventually exceed the number of allowed threads if you’re not checking if a thread is currently running on a row.

    DOWNLOAD LINK: https://www.dropbox.com/s/pvr9zyl811tfeem/ListViewImageCache.zip

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

Sidebar

Related Questions

1.Check condition only display public View getView(final int position, View convertView, ViewGroup parent) {
@Override public View getView(final int position, View convertView, ViewGroup parent) { View v =
public View getView(int position, View convertView, ViewGroup parent) { Button btn; if (convertView ==
this is my getView method: public View getView(final int position, View convertView, final ViewGroup
I try to create listView dynamically from code with: @Override public View getView(int position,
public class ExpAdapter : BaseExpandableListAdapter { private int seed = 1000; public override View
Loading class (View): public class Loading extends View { private long movieStart; private Movie
I have a custom view: public class Loading extends View { private long movieStart;
Why can't I use the function ColPeekHeight() as an l-value? class View { public:
I have a painfully simple view model public class TellAFriendViewModel { public string Email1

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.