1. Download our Official Android App: Forums for Android!

I create a Adapter (extends ResourceCursorAdapter)for listView,but the app always out of memory

Discussion in 'Android Lounge' started by zxxjj, Jun 4, 2011.

  1. zxxjj

    zxxjj Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Jun 4, 2011

    Jun 4, 2011
    2
    0
    5
    Hi all,
    Following is the Adapter I create; I'm sure it must be the problem of the

    adapter, but i don't know what is wrong in it ; my app can be start ,but

    it only can running for a while ,then the Eclipse Logcat tell me the

    error:: ERROR/JavaBinder(1496): java.lang.RuntimeException: No memory in memObj

    I hope your help , I really don't know why, HELP!!!!!

    THANK YOU!!!!:p;):D:eek::):(:thinking::eek::cool:

    you can also tell me by email ---zxxjjforever@gmail.com!

    private class ContactListItemAdapter extends ResourceCursorAdapter {
    public ContactListItemAdapter(Context context, int layout, Cursor c) {
    super(context, layout, c);
    }


    @Override
    public void bindView(View view, Context context, Cursor cursor) {
    System.out.println(" bindView");
    final ContactListItemCache cache = (ContactListItemCache) view
    .getTag();

    TextView nameView = cache.nameView;
    QuickContactBadge photoView = cache.photoView;

    nameView.setText(cursor.getString(SUMMARY_NAME_COLUMN_INDEX));
    final long contactId = cursor.getLong(SUMMARY_ID_COLUMN_INDEX);
    final String lookupKey = cursor.getString(SUMMARY_LOOKUP_KEY);
    int photoid = cursor.getInt(SUMMARY_PHOTO_ID_COLUMN_INDEX);
    photoView.setMode(QuickContact.MODE_SMALL);
    photoView.assignContactUri(Contacts.getLookupUri(contactId,
    lookupKey));
    if (getPhoto(context, photoid) != null) {
    photoView.setImageDrawable(getPhoto(context, photoid));
    } else {
    photoView.setImageResource(R.drawable.ic_contact_picture);
    }

    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
    View view = super.newView(context, cursor, parent);
    ContactListItemCache cache = null;

    cache = new ContactListItemCache();
    cache.nameView = (TextView) view.findViewById(R.id.name);
    cache.photoView = (QuickContactBadge) view.findViewById(R.id.badge);

    view.setTag(cache);
    System.out.println("View newView");

    return view;

    }

    }

    static class ContactListItemCache {
    public TextView nameView;
    public QuickContactBadge photoView;

    ContactListItemCache() {
    System.out.println("ContactListItemCache");
    }

    }
     

    Advertisement

Share This Page

Loading...