hi Dmitri, thanks for your reply. any way i've tried to do what you ask me to do.
in the
@Override
public View newView(Context context, Cursor cursor, ViewGroup
parent) {
// TODO Auto-generated method stub
Cursor c = getCursor();
try {
// int idCol = c.getColumnIndex(Phones._ID);
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) v
.findViewById(R.id.contactName);
if (name_text != null) {
name_text.setText(name);
}
TextView num_text = (TextView)
v.findViewById(R.id.number);
if (num_text != null) {
num_text.setText(number);
}
// set the profile picture
ImageView profile = (ImageView)
v.findViewById(R.id.imgContact);
if (profile != null) {
// retrieve the contact photo as a
Bitmap
// 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)
v.findViewById(R.id.is);
boolean b = isAssign(number);
if (b) {
// set the profile picture
indicator.setImageResource(R.drawable.ok);
} else {
indicator.setImageResource(R.drawable.delete);
}
dialog.dismiss();
return v;
} finally {
if (cursor != null) {
cursor.close();
}
}
}
is this correct
then i'm getting a exception saying closed cursor in the bindView
method
@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();
}
}
}
when i remove the try,finally block in the newView method only one
Contact is displayed???
any idea???
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

