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

