Android: Removing "The" from listview items -
i have received several requests adjust way list items displayed on media player application.
currently entry beginning "the" sorted t's expect. many users sort item using second word in title.
can shed light on done? adjusted while getting cursor or when applying listview?
any appreciated.
thank you, josh
update:
thank answers, still struggling find apply solutions suggested in instance.
i using simple cursor acquire dataset. snippet of code below:
audiocursor = getcontentresolver().query(mediastore.audio.artists.external_content_uri, cols, null, null,audiocolumns.artist + " collate localized asc"); startmanagingcursor(audiocursor); setlistadapter(new myabcadapter(this, r.layout.list_item, audiocursor, new string[]{audiocolumns.artist,mediastore.audio.artists.number_of_tracks}, new int[]{android.r.id.text1, android.r.id.text2}));
i have utility adjusts entry text, changing "the artist" "artist, the", not applied until bindview , list has been sorted:
private string fixfilename(string filename) { ... if (filename.startswith("the")){ filename = filename.replace("the ", ""); filename = filename.concat(",the"); } return filename; }
my questions are:
1) there way apply fixfilename cursor before list created? 2) if not possible, there way resort listview after bindview?
thanks!
have list items extend comparable. in compareto(..)
method, write custom compare code, using "the".equalsignorecase(filename.substring(0, 3))
, make "the..." special case.
Comments
Post a Comment