adapter = new SimpleCursorAdapter(this,
R.layout.inbox_list, mCursor, new String[] {
Domain.Message.FROM,
Domain.Message.END, Domain.Message.START },
new int[] {
R.id.image, R.id.text1,
R.id.text2 });
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder(){
public boolean setViewValue(View view, Cursor cursor,
int
columnIndex) {
// TODO Auto-generated method stub
// Log.v(LOG_TAG, "setViewValue");
// Log.v(LOG_TAG, "columnIndex:" + columnIndex);
// Log.v(LOG_TAG, "column:" +
cursor.getString(columnIndex));
int resid = 0;
if(columnIndex ==
cursor.getColumnIndex(Domain.Message.FROM)) {
ImageView iv = (ImageView)view;
Log.v(LOG_TAG, "list type:" +
cursor.getInt(cursor.getColumnIndex(Domain.Message.TYPE)));
if(cursor.getInt(cursor.getColumnIndex(Domain.Message.TYPE)) ==
0) {
if(cursor.getInt(cursor.getColumnIndex(Domain.Message.READ)) ==
0) {
resid =
R.drawable.msg_ask_new;
} else {
resid =
R.drawable.msg_ask_read;
}
} else {
if(cursor.getInt(cursor.getColumnIndex(Domain.Message.READ)) ==
0) {
resid =
R.drawable.msg_reply_new;
} else {
resid =
R.drawable.msg_reply_read;
}
}
if(resid != 0) {
iv.setImageResource(resid);
return true;
}
}
return false;
}
});
setListAdapter(adapter);
On Apr 2, 4:18 am, Tofik <[EMAIL PROTECTED]> wrote:
> Hello. I have object type in DB (integer field 1, 2, 3 ... 8). Each
> object type corresponds to image, which is stored in drawable
> directory. I want to display list of objects with their images. I
> found solution, using SimpleCursorAdapter. It bind image from DB, but
> in this case I have to store image in DB, which is unnecessary,
> because I have object type. Can you please help me, how can I solve
> this problem?
>
> Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---