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? :(
If you agree I will give you my source code?

On 25 sep, 20:35, Marco Nelissen <[email protected]> wrote:
> On Fri, Sep 25, 2009 at 10:18 AM, Wouter <[email protected]> wrote:
>
> > On 25 sep, 16:57, Marco Nelissen <[email protected]> wrote:
> >> So there's your problem then, probably. The adapter expects each item
> >> to have the same items, so that it can assign the fields from your
> >> Cursor to the corresponding items in your list item layout. In other
> >> words, if your "normal" list item contains items with IDs A, B and C,
> >> them your "section" list items should also have items with IDs A, B
> >> and C, and those items should have the same type in both layouts as
> >> well.
>
> > So if i understand this good if have to use the same layout file for
> > my header file (that only needs a TextView) and my list item (with
> > much more information and many TextViews and a ImageView).
>
> Yes, if you're expecting the adapter to fill the various views in your
> layouts with data automatically.
>
>
>
> > My list_header.xml file is like this:
>
> > <?xml version="1.0" encoding="UTF-8"?>
> >  <TextView
>
> >     xmlns:android="http://schemas.android.com/apk/res/android";
> >     android:id="@+id/list_header_title"
> >     android:layout_width="fill_parent"
> >     android:layout_height="wrap_content"
> >     android:text="header"
> >     android:textColor="#FFFFFF"
> >     android:gravity="center_vertical|left"
> >        android:paddingLeft="20dip"
>
> >      android:background="@drawable/settings_header"
> >     android:textAppearance="?android:attr/textAppearanceSmall"
> >  />
>
> > I use this to set up a text for my heade. I use the
> > seperatedlistadapter from here:
> >http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-...
>
> >>In your case, it looks like you have a TextView with a given ID
> >> in one layout, whereas in the other layout that same ID is either used
> >> for something that is not a TextView, or isn't present at all.
>
> > And I don't have a textview with the same ID.
>
> and that is why it complains/crashes.
>
> >> If you need some of the items in your list to be different between
> >> your "normal" and "section" layouts, then you should override bindView
> >> and handle that in there.
>
> > And how can i do that? I now use getView to make my list items in my
> > custom adapter and i only do this for my seperatedlistadapter:
>
> > adapter.addSection(parsed, new cinemaAdapter(this,
> > R.layout.list_header, cinema));
>
> > How can i use BindView then? I will give you my source code if you
> > want!
>
> There are several ways you can accomplish what you want to do.
> The easiest is probably to have a single layout that you can use for
> both types of items, by hiding and showing views as needed. I don't
> think it matters whether you hide/show these views in getView or in
> bindView. What matters is that both layouts have all the views
> present, so that the adapter doesn't get confused.
> Slightly more sophisticated would be to use different layouts for the
> two types of items, and then implement bindView() to only assign data
> to those views that are actually present in the layout for each item.
--~--~---------~--~----~------------~-------~--~----~
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