I don't see anything obviously wrong with your code. I do notice that you apparently create the SeparatedListAdapter and then immediately call setListAdapter with it, whereas the SeparatedListAdapter sample code creates the adapter, then adds a bunch of sections to it, and then calls setListAdapter at the end. Could it be that SeparatedListAdapter doesn't work when it is empty? Have you tried postponing your call to setListAdapter until after you've added all the sections?
On Sun, Sep 27, 2009 at 12:32 PM, Wouter <[email protected]> wrote: > > Ok i will try to explain how i generate my headers with the > seperatedlistadapter.. > > private SeparatedListAdapter adapter; > > in my setupViews functions: > > this.adapter = new SeparatedListAdapter(this); > setListAdapter(adapter); > > And then to retrieve my data: > > �...@suppresswarnings("unchecked") > public void retrieveCinema() > { > try { > HashMap<String, Object> response = (HashMap<String, > Object>) > client.call("film.retrieveCinema", sessionKey); > > Comparator reverse = Collections.reverseOrder(); > > TreeMap<String, Object> result = new TreeMap<String, > Object> > (reverse); > TreeMap<String, Object> sortedMap = new > TreeMap<String, Object> > (response); > result.putAll(sortedMap); > > Iterator it = result.entrySet().iterator(); > > while (it.hasNext()) { > cinema = new ArrayList<FilmDetail>(); > Map.Entry pairs = (Map.Entry)it.next(); > Object[] cinemaFilms = (Object[])pairs.getValue(); > FilmDetail cinemaMovie = new FilmDetail(); > > for (int i=0; i<cinemaFilms.length; i++) > { > cinemaMovie = new FilmDetail(); > Map m = (Map) cinemaFilms[i]; > cinemaMovie.setTitle(m.get("title").toString()); > cinemaMovie.setYear(m.get("year").toString()); > > cinemaMovie.setVotes_count(m.get("votes_count").toString()); > > cinemaMovie.setActors_text(m.get("actors_text").toString()); > cinemaMovie.setDirectors_text(m.get > ("directors_text").toString()); > > cinemaMovie.setGenres_text(m.get("genres_text").toString()); > cinemaMovie.setAverage(m.get("average").toString()); > cinemaMovie.setFilmId(m.get("filmId").toString()); > cinemaMovie.setDuration(m.get("duration").toString()); > cinema.add(cinemaMovie); > } > > String datum = pairs.getKey().toString(); > SimpleDateFormat formatter = new > SimpleDateFormat("EEEEEE d > MMMMMM"); > formatter.applyLocalizedPattern("EEEEEE d MMMMMM"); > int year= Integer.valueOf(datum.substring(0,4)); > int month = Integer.valueOf(datum.substring(5,7)); > int day = Integer.valueOf(datum.substring(8,10)); > java.util.Date date = new java.util.Date(year, month, > day); > String parsed = formatter.format(date); > > System.out.println(parsed); > > adapter.addSection(parsed, new cinemaAdapter(this, > cinema)); > > } > > > > } catch (XMLRPCException e) { > e.printStackTrace(); > } > runOnUiThread(returnRes); > > > } > > And for every date in my response i do this > > adapter.addSection(parsed, new cinemaAdapter(this, cinema)); > > and parsed is the parsed text from date (example 31 october)) > > And this is how i generate it! > It there an error somewhere? > On 27 sep, 20:23, Marco Nelissen <[email protected]> wrote: >> On Sun, Sep 27, 2009 at 6:01 AM, Wouter <[email protected]> wrote: >> >> > On 26 sep, 19:10, Marco Nelissen <[email protected]> wrote: >> >> On Sat, Sep 26, 2009 at 6:20 AM, Wouter <[email protected]> wrote: >> >> >> > When i look at the sample from the seperatedlistadapter i see this: >> >> >> > # @Override >> >> > # public void onCreate(Bundle icicle) { >> >> > # super.onCreate(icicle); >> >> > # >> >> > # List<Map<String,?>> security = new LinkedList<Map<String,?>> >> >> > (); >> >> > # security.add(createItem("Remember passwords", "Save >> >> > usernames and passwords for Web sites")); >> >> > # security.add(createItem("Clear passwords", "Save usernames >> >> > and passwords for Web sites")); >> >> > # security.add(createItem("Show security warnings", "Show >> >> > warning if there is a problem with a site's security")); >> >> > # >> >> > # // create our list and custom adapter >> >> > # SeparatedListAdapter adapter = new SeparatedListAdapter >> >> > (this); >> >> > # adapter.addSection("Array test", new ArrayAdapter<String> >> >> > (this, >> >> > # R.layout.list_item, new String[] { "First item", "Item >> >> > two" })); >> >> > # adapter.addSection("Security", new SimpleAdapter(this, >> >> > security, R.layout.list_complex, >> >> > # new String[] { ITEM_TITLE, ITEM_CAPTION }, new int[] >> >> > { R.id.list_complex_title, R.id.list_complex_caption })); >> >> > # >> >> > # ListView list = new ListView(this); >> >> > # list.setAdapter(adapter); >> >> > # this.setContentView(list); >> >> > # >> >> > # } >> >> >> > so every section is using a different layout file. So why doestn't >> >> > this work with me? :( >> >> >> The specific crash you're seeing is caused by the wrong layout being >> >> used for a list item, that much is clear from the log. It's hard to >> >> say whether this is because you're using this SeparatedListAdapter >> >> wrong, or because there's a bug in it. With SeparatedListAdapter >> >> you're actually using multiple adapters (one for each section, and one >> >> for all the section-headers), which makes it a little harder to debug. >> >> You could start by adding lots of logging, so you can see what >> >> position it's trying to get a view for, what section and layout it >> >> thinks that position corresponds to and then check whether that layout >> >> actually has all the fields that that section's adapter needs. >> >> >> On thing that's a bit suspicious about the code you've posted so far >> >> is that you appear to be assigning values (data) to the various views >> >> in your getView(), which is not what you would normally do. Normally >> >> getView only returns a layout of the correct type, and the adapter >> >> itself then assigns the data from the array or Cursor to the various >> >> views in your layout. >> >> > Hmm, i only use on view to assign values to (R.layout.cinema_row): >> >> You are also assigning values to a lot of the child views of that >> layout (all of those calls to setText). On second thought I don't >> think that is actually the problem though. >> Given where it crashed, the problem is with the adapter you specified >> for the section headers, which if I understand correctly is not >> cinemaAdapter, but some other adapter (possibly a plain ArrayAdapter) >> that displays dates. If you post the code for that (how do you create >> it), we can probably sort this out. > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

