MatrixCursor addRow and Drawable Resource

All your problems with Audio, Video and Images.

MatrixCursor addRow and Drawable Resource

Postby Keenora » Wed Feb 03, 2010 2:18 pm

Hey Guys!
I've got the following problem: I've got an ArrayList with many values. Now, I want to put some of them into my ListView. The problem is, that this ListView contains an ImageView, which I want to fill with a BLOB field out of my ArrayList. My code looks like this wihout errors:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. String[] menuCols = new String[] { mDbHelper.KEY_IMAGES, mDbHelper.KEY_NAME, mDbHelper.KEY_TIME };
  3.  
  4. int[] to = new int[] { R.id.image, R.id.name, R.id.time };
  5.  
  6.  
  7.  
  8.  
  9.  
  10. MatrixCursor menuCursor = new MatrixCursor(menuCols);
  11.  
  12. startManagingCursor(menuCursor);                   
  13.  
  14.  
  15.  
  16. for(int i = 0;i < res.length; i++) {
  17.  
  18.         resInner = (String[]) res[i];                          
  19.  
  20.         menuCursor.addRow(new Object[] { R.drawable.icon, resInner[1], resInner[0] }); 
  21.  
  22. }
  23.  
  24.  
  25.  
  26. SimpleCursorAdapter menuItems = new SimpleCursorAdapter( this, R.layout.row, menuCursor, menuCols, to);        
  27.  
  28. setListAdapter(menuItems);
  29.  
  30.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


So, I've got my ListView with the AppIcon at the beginning of each entry. Now I need to load the image out of the BLOB Field, which is "resInner[6]". How do I do this? I already tried to put it in an ImageView somehow...but...well, it just failed ^^°

So, how could I do this?
User avatar
Keenora
Freshman
Freshman
 
Posts: 5
Joined: Wed Feb 03, 2010 2:08 pm

Top

Postby Koxx » Sun Mar 21, 2010 7:02 pm

I have the same problem.

It seems there is a problem to pass BLOB with MatrixCursor...
Koxx
Freshman
Freshman
 
Posts: 6
Joined: Sat Jun 13, 2009 3:08 pm
Location: PARIS

Postby Keenora » Fri Mar 26, 2010 4:13 pm

Probably true. I just took another way, to get the images right now. For me it was even simpler, because I put the images directly after an update of my data, to a shared folder on the SD Card. After all it was more senseful to do it like that, because the database otherwise had increased to something over 6MiB...which wasn't my intention ;)

So I just store the URLs in it, create a md5 hash to the urls and save the images under that name on the card. Also the last timestamp, which I get through my updatepart, is saved in the name. Then, on a real update, I check these both things and load the picture, or just take the cached one. Due the fact, that I have to store something about ~200 images, it was necessary to do it like this. For example because of the reason, that the phone storage is limited and the SD Card has to be there anyway.
User avatar
Keenora
Freshman
Freshman
 
Posts: 5
Joined: Wed Feb 03, 2010 2:08 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 15 guests