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

 public View getView(int position, View convertView, ViewGroup parent)
{
                View v = convertView;
                FilmDetail o = items.get(position);

                if (v == null) {
                    LayoutInflater vi = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.cinema_row, parent,
false);
                }

                if (o != null) {
                        TextView tt = (TextView) v.findViewById
(R.id.text1);
                        TextView genre = (TextView) v.findViewById
(R.id.genre);
                        TextView directors = (TextView) v.findViewById
(R.id.regisse..

As you can see here.. So I don't think this is the problem..
Do you have an example of how i can use getView then in the way you
are saying?

> > If you agree I will give you my source code?
>
> Sorry, no. If you're OK with sharing your code, you should post it
> here (as minimal an example as possible) so that others can help and
> learn from it too.

I have posted a lot of my activity so i hope someone else can help me
too..
--~--~---------~--~----~------------~-------~--~----~
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