The position is passed in as a parameter, and presumably you know
which layout you want to use for a given position, so you can return
the appropriate layout here.
Alternatively, you could return a view that can serve as any of the
layouts you need (by showing and hiding elements as needed), and then
in your bindView() you tweak the layout to be what you want. The
latter approach might be more inefficient because you end up using
more views.



On Thu, Aug 13, 2009 at 3:21 PM, Wouter<[email protected]> wrote:
>
> I have a custom adapter like this:
>
>  private class FriendsAdapter extends ArrayAdapter<Profile> {
> ..
>
> public View getView(int position, View convertView, ViewGroup parent)
> {
>                View v = convertView;
>                if (v == null) {
>                    LayoutInflater vi = (LayoutInflater)
> getSystemService(Context.LAYOUT_INFLATER_SERVICE);
>                    v = vi.inflate(R.layout.friend_row, null);
>                }
>
> So i use getView and Layoutinflater..
> I have to make a new View like I did already, but now for other rows?
> Would be great :D
>
> Thx
>
> On 14 aug, 00:11, Marco Nelissen <[email protected]> wrote:
>> On Thu, Aug 13, 2009 at 3:00 PM, Wouter<[email protected]> wrote:
>>
>> > Hey,
>>
>> > I want to make a listview that has different rows (layouts). I will
>> > load the data from a webservice and it can be 2 or more layouts i have
>> > to generate then. I am creating a social network app and want to show
>> > a stream of the users activity.
>> > So when he made a comment, make a new friend, this all has to come in
>> > the same list.. I load 1 XML file with multiple different child
>> > objects (comment, friend) so i can see which layout i have to use.
>>
>> > I have saw this at the Brightkite android app:
>>
>> >http://www.grabup.com/uploads/c278f22e9bd19a2ccac2246ebd85326c.png?di...
>>
>> > user checked in, posted note --> different rows..
>>
>> > But I don't know how to do that.. I use a custom adapter for my
>> > listview but i only can choose one row layout for my list..
>>
>> If you have your own adapter, then you can do pretty much whatever you
>> want in newView and/or bindView.
> >
>

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