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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:27:01+00:00 2026-06-09T12:27:01+00:00

I’m having this classcastexception I combine lazylist by Fedor and Endless by Commonware i’m

  • 0

I’m having this classcastexception
I combine lazylist by Fedor and Endless by Commonware

i’m having this error

08-09 18:06:26.553: E/AndroidRuntime(314): FATAL EXCEPTION: main
08-09 18:06:26.553: E/AndroidRuntime(314): java.lang.ClassCastException:com.example.endlesscustom.EndlessSample$CustomArrayAdapter
08-09 18:06:26.553: E/AndroidRuntime(314):  at com.example.endlesscustom.EndlessSample$DemoAdapter.appendCachedData(EndlessSample.java:174)
08-09 18:06:26.553: E/AndroidRuntime(314):  at com.commonsware.cwac.endless.EndlessAdapter$AppendTask.onPostExecute(EndlessAdapter.java:247)

It pointed out this error

ArrayAdapter<HashMap<String, String>> arrAdapterNew = ArrayAdapter<HashMap<String,String>>) getWrappedAdapter();

Here is my Code

public class EndlessSample extends ListActivity {

static int LIST_SIZE;
private int mLastOffset = 0;

static final int BATCH_SIZE = 3;

ArrayList<HashMap<String, String>> countriesSub = new ArrayList<HashMap<String, String>>();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maina);
    init();
    Log.i("country", String.valueOf(COUNTRIES.length));
    Log.i("mstrings", String.valueOf(mStrings.length));

}

private void init() {
    LIST_SIZE = COUNTRIES.length;
    for (int i = 0; i <= BATCH_SIZE; i++) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("country", COUNTRIES[i]);
        map.put("pic", mStrings[i]);
        countriesSub.add(map);
    }
    setLastOffset(BATCH_SIZE);
    displayList(countriesSub);
}

private void setLastOffset(int i) {
    mLastOffset = i;
}

private int getLastOffset() {
    return mLastOffset;
}

private void displayList(ArrayList<HashMap<String, String>> countriesSub2) {
    setListAdapter(new DemoAdapter());
}

private class CustomArrayAdapter extends BaseAdapter {
    public ImageLoader imageLoader;
    private ArrayList<HashMap<String, String>> data;

    public CustomArrayAdapter(Context context, int resource,
            int textViewResourceId,
            ArrayList<HashMap<String, String>> mylist) {
        data = mylist;
        imageLoader = new ImageLoader(context);
    }

    public int getCount() {
        return data.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder;
        HashMap<String, String> song = new HashMap<String, String>();

        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) EndlessSample.this
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.row, null);
            holder = new ViewHolder();
            holder.word = (TextView) convertView
                    .findViewById(R.id.throbber);
            holder.pecture = (ImageView) convertView
                    .findViewById(R.id.imahe);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        Log.i("data size", String.valueOf(data.size()));
        song = data.get(position);
        holder.word.setText(song.get("country"));
        // holder.word.setText(String.valueOf(position + 1) + ". "
        // + countriesSub.get(position));
         imageLoader.DisplayImage(song.get("pic"), holder.pecture);
        return convertView;
    }

    public class ViewHolder {
        public ImageView pecture;
        public TextView word;
    }
}

class DemoAdapter extends EndlessAdapter {
    ArrayList<HashMap<String, String>> tempList = new ArrayList<HashMap<String, String>>();

    DemoAdapter() {
        super(new CustomArrayAdapter(EndlessSample.this,
                android.R.layout.simple_list_item_1, android.R.id.text1,
                countriesSub));

    }

    @Override
    protected View getPendingView(ViewGroup parent) {
        View row = getLayoutInflater().inflate(R.layout.row, null);

        View child = row.findViewById(android.R.id.text1);
        // child.setVisibility(View.GONE);
        child = row.findViewById(R.id.throbber);
        child.setVisibility(View.VISIBLE);

        return (row);
    }

    @Override
    protected boolean cacheInBackground() {
        tempList.clear();
        int lastOffset = getLastOffset();
        if (lastOffset < LIST_SIZE) {
            int limit = lastOffset + BATCH_SIZE;
            for (int i = (lastOffset + 1); (i <= limit && i < LIST_SIZE); i++) {
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("country", COUNTRIES[i]);
                map.put("pic", mStrings[i]);
                tempList.add(map);
            }
            setLastOffset(limit);

            if (limit < LIST_SIZE) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }

    @Override
    protected void appendCachedData() {

        @SuppressWarnings("unchecked")
        ArrayAdapter<HashMap<String, String>> arrAdapterNew = (ArrayAdapter<HashMap<String, String>>) getWrappedAdapter();
        int listLen = tempList.size();
        for (int i = 0; i < listLen; i++) {
            arrAdapterNew.add(tempList.get(i));
        }
    }
}

static final String[] COUNTRIES = new String[] { "Afghanistan", "Albania",
        "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla",
        "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia",
        "Aruba", "Australia", "Austria", "Azerbaijan", "Bahrain",
        "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin",
        "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina",
        "Botswana", "Bouvet Island", "Brazil",
        "British Indian Ocean Territory", "British Virgin Islands",
        "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cote d'Ivoire",
        "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands",
        "Central African Republic", "Chad", "Chile", "China",
        "Christmas Island", "Cocos (Keeling) Islands", "Colombia",
        "Comoros", "Congo", "Cook Islands", "Costa Rica", "Croatia",
        "Cuba", "Cyprus", "Czech Republic",
        "Democratic Republic of the Congo", "Denmark", "Djibouti",
        "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt",
        "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia",
        "Ethiopia", "Faeroe Islands", "Falkland Islands", "Fiji",
        "Finland", "Former Yugoslav Republic of Macedonia", "France",
        "French Guiana", "French Polynesia", "French Southern Territories",
        "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece",
        "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala",
        "Guinea", "Guinea-Bissau", "Guyana", "Haiti",
        "Heard Island and McDonald Islands", "Honduras", "Hong Kong",
        "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq",
        "Ireland", "Israel", "Italy", "Jamaica" };

private String[] mStrings = {
        "http://a3.twimg.com/profile_images/670625317/aam-logo-v3-twitter.png",
        "http://a3.twimg.com/profile_images/740897825/AndroidCast-350_normal.png",
        "http://a3.twimg.com/profile_images/121630227/Droid_normal.jpg",
        "http://a1.twimg.com/profile_images/957149154/twitterhalf_normal.jpg",
        "http://a1.twimg.com/profile_images/97470808/icon_normal.png",
        "http://a3.twimg.com/profile_images/511790713/AG.png",
        "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
        "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
        "http://a3.twimg.com/profile_images/72774055/AndroidHomme-LOGO_normal.jpg",
        "http://a1.twimg.com/profile_images/349012784/android_logo_small_normal.jpg",
        "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon.png",
        "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
        "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
        "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300_normal.jpg",
        "http://a1.twimg.com/profile_images/655119538/andbook.png",
        "http://a3.twimg.com/profile_images/768060227/ap4u_normal.jpg",
        "http://a1.twimg.com/profile_images/74724754/android_logo_normal.png",
        "http://a3.twimg.com/profile_images/681537837/SmallAvatarx150_normal.png",
        "http://a1.twimg.com/profile_images/63737974/2008-11-06_1637_normal.png",
        "http://a3.twimg.com/profile_images/548410609/icon_8_73.png",
        "http://a1.twimg.com/profile_images/612232882/nexusoneavatar_normal.jpg",
        "http://a1.twimg.com/profile_images/213722080/Bugdroid-phone_normal.png",
        "http://a1.twimg.com/profile_images/645523828/OT_icon_090918_android_normal.png",
        "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
        "http://a3.twimg.com/profile_images/77641093/AndroidPlanet.png",
        "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300_normal.jpg",
        "http://a1.twimg.com/profile_images/655119538/andbook_normal.png",
        "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
        "http://a3.twimg.com/profile_images/956404323/androinica-avatar.png",
        "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
        "http://a3.twimg.com/profile_images/72774055/AndroidHomme-LOGO_normal.jpg",
        "http://a1.twimg.com/profile_images/349012784/android_logo_small_normal.jpg",
        "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon_normal.png",
        "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
        "http://a3.twimg.com/profile_images/77641093/AndroidPlanet.png",
        "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
        "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
        "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300.jpg",
        "http://a1.twimg.com/profile_images/655119538/andbook_normal.png",
        "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
        "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
        "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
        "http://a3.twimg.com/profile_images/121630227/Droid.jpg",
        "http://a1.twimg.com/profile_images/957149154/twitterhalf_normal.jpg",
        "http://a1.twimg.com/profile_images/97470808/icon_normal.png",
        "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
        "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
        "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man.png",
        "http://a3.twimg.com/profile_images/72774055/AndroidHomme-LOGO_normal.jpg",
        "http://a1.twimg.com/profile_images/349012784/android_logo_small_normal.jpg",
        "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon_normal.png",
        "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
        "http://a3.twimg.com/profile_images/77641093/AndroidPlanet.png",
        "http://a3.twimg.com/profile_images/670625317/aam-logo-v3-twitter_normal.png",
        "http://a3.twimg.com/profile_images/740897825/AndroidCast-350_normal.png",
        "http://a3.twimg.com/profile_images/121630227/Droid_normal.jpg",
        "http://a1.twimg.com/profile_images/957149154/twitterhalf_normal.jpg",
        "http://a1.twimg.com/profile_images/97470808/icon.png",
        "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
        "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
        "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
        "http://a3.twimg.com/profile_images/72774055/AndroidHomme-LOGO_normal.jpg",
        "http://a1.twimg.com/profile_images/349012784/android_logo_small_normal.jpg",
        "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon.png",
        "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
        "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
        "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300_normal.jpg",
        "http://a1.twimg.com/profile_images/655119538/andbook_normal.png",
        "http://a3.twimg.com/profile_images/768060227/ap4u_normal.jpg",
        "http://a1.twimg.com/profile_images/74724754/android_logo.png",
        "http://a3.twimg.com/profile_images/681537837/SmallAvatarx150_normal.png",
        "http://a1.twimg.com/profile_images/63737974/2008-11-06_1637_normal.png",
        "http://a3.twimg.com/profile_images/548410609/icon_8_73_normal.png",
        "http://a1.twimg.com/profile_images/612232882/nexusoneavatar_normal.jpg",
        "http://a1.twimg.com/profile_images/213722080/Bugdroid-phone_normal.png",
        "http://a1.twimg.com/profile_images/645523828/OT_icon_090918_android.png",
        "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
        "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
        "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300_normal.jpg",
        "http://a1.twimg.com/profile_images/655119538/andbook.png",
        "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
        "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
        "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
        "http://a3.twimg.com/profile_images/72774055/AndroidHomme-LOGO_normal.jpg",
        "http://a1.twimg.com/profile_images/349012784/android_logo_small_normal.jpg",
        "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon.png",
        "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
        "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
        "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
        "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png",
        "http://a1.twimg.com/profile_images/850960042/elandroidelibre-logo_300x300_normal.jpg",
        "http://a1.twimg.com/profile_images/655119538/andbook_normal.png",
        "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
        "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
        "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
        "http://a3.twimg.com/profile_images/121630227/Droid_normal.jpg",
        "http://a1.twimg.com/profile_images/957149154/twitterhalf.jpg",
        "http://a1.twimg.com/profile_images/97470808/icon_normal.png",
        "http://a3.twimg.com/profile_images/511790713/AG_normal.png",
        "http://a3.twimg.com/profile_images/956404323/androinica-avatar_normal.png",
        "http://a1.twimg.com/profile_images/909231146/Android_Biz_Man_normal.png",
        "http://a3.twimg.com/profile_images/72774055/AndroidHomme-LOGO_normal.jpg",
        "http://a1.twimg.com/profile_images/349012784/android_logo_small.jpg",
        "http://a1.twimg.com/profile_images/841338368/ea-twitter-icon_normal.png",
        "http://a3.twimg.com/profile_images/64827025/android-wallpaper6_2560x160_normal.png",
        "http://a3.twimg.com/profile_images/77641093/AndroidPlanet_normal.png" };
}

if anyone had encounter this error please help

thankyou so much

  • 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-09T12:27:02+00:00Added an answer on June 9, 2026 at 12:27 pm

    The adapter you are putting into EndlessAdapter is a CustomArrayAdapter, not an ArrayAdapter<HashMap<String, String>>, which is why you get a ClassCastException when trying to cast the CustomArrayAdapter to ArrayAdapter<HashMap<String, String>> as part of your call to getWrappedAdapter().

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

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.