Ah, SQL injection...

23.05.2011 4:54, Gabriel Simões пишет:
Thanks once again Kostya,

I came up with a cleaner solution that still has one thing left to
work:

Instead of using Media.Audio.Album I got to using only
Media.Audio.Media. It works as expected but the lack of the "_id"
column now is giving my a big headache when loading the Adapter.
I tried to use

         String[] cols = new String[] {
                        "distinct " + MediaStore.Audio.Media.ALBUM_ID + " as 
_id",
                        MediaStore.Audio.Media.ALBUM,
                        MediaStore.Audio.Media.ARTIST
         };

But it simply doesn´t work. How can I fix the Adapter dependency of
_id so my expandablelistview works?

Thanks,
Gabriel Simões

On May 22, 2:42 pm, Kostya Vasilyev<[email protected]>  wrote:
22.05.2011 21:13, Gabriel Simões пишет:

My second approach was to find a way to block the displaying of some
entries creating a custom adapter but while I can change the
information I couldn´t find a way to not display full entries.
Ok, here is how you could do filtering on the fly.

Assume the data set you get from CP in a cursor is like this:

0 - mp3
1 - mp3
2 - no mp3
3 - mp3
4 - no mp3

Look through the cursor, checking for mp3s, and create a parallel index
array like this:

[ 0, 1, 3 ]

The array has the cursor positions where albums have mp3.

Now you have the count for the adapter's getCount method, which is the
length of this array. The positions as seen by the list view are 0
through 2.

In getView / bindView, use the table above to find out the position for
the original cursor: the 0th item is remapped to 0, 1 is mapped to 1,
but 2 is mapped to 3.

-- Kostya

--
Kostya Vasilyev --http://kmansoft.wordpress.com


--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
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

Reply via email to