hi Dmitri,
according to my findings the newView method is not needed. only
bindView is enough. now i have about 600 + contacts.
this is the exception that i'm getting
05-31 13:39:22.180: ERROR/JavaBinder(564): java.lang.RuntimeException:
No memory in memObj
when i followed your instructions i have surrounded the method using a
try/finally block then only the first contact displays.
@Override
public void bindView(View view, Context context,
Cursor c) {
// TODO Auto-generated method stub
// int idCol = c.getColumnIndex(Phones._ID);
try {
int nameCol =
c.getColumnIndex(Phones.NAME);
int numCol =
c.getColumnIndex(Phones.NUMBER);
int foreign =
c.getColumnIndex(Phones.PERSON_ID);
String name = c.getString(nameCol);
String number = c.getString(numCol);
// long id = c.getLong(idCol);
long phoneForeign =
c.getLong(foreign);
// View v =
mInflater.inflate(R.layout.contacts, parent, false);
TextView name_text = (TextView) view
.findViewById(R.id.contactName);
if (name_text != null) {
name_text.setText(name);
}
TextView num_text = (TextView)
view.findViewById(R.id.number);
if (num_text != null) {
num_text.setText(number);
}
// set the profile picture
ImageView profile = (ImageView) view
.findViewById(R.id.imgContact);
if (profile != null) {
// Uri uri =
ContentUris.withAppendedId(People.CONTENT_URI,
// id);
Cursor cur =
getContentResolver().query(Photos.CONTENT_URI,
null,
Photos.PERSON_ID + "='" + phoneForeign + "'",
null, null);
byte[] b = null;
if (cur != null) {
if (cur.moveToNext())
{
int imgColumn
= cur.getColumnIndex(Photos.DATA);
b =
cur.getBlob(imgColumn);
}
}
Bitmap bm = null;
if (b != null) {
ByteArrayInputStream
bytes = new ByteArrayInputStream(b);
BitmapDrawable bmd =
new BitmapDrawable(bytes);
bm = bmd.getBitmap();
profile.setImageBitmap(bm);
} else {
profile.setImageResource(R.drawable.defaultcontact);
}
ImageView indicator =
(ImageView) view
.findViewById(R.id.is);
boolean assign =
isAssign(number);
if (assign) {
// set the profile
picture
indicator.setImageResource(R.drawable.ok);
} else {
indicator.setImageResource(R.drawable.delete);
}
}
} finally {
if (c != null) {
c.close();
}
}
}
regards,
Randika
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en