Multiple List-Item Layouts in One ListView


Last Updated:

  1. Andrew McCandless

    Andrew McCandless Member This Topic's Starter

    Joined:
    Mar 8, 2010
    Messages:
    7
    Likes Received:
    0
    Hi there,

    I'm trying to write a ListActivity that displays heirarchical information in the following manner:

    • The first item in the list displays the current node in a tree of items.
    • The second item displays information about the parent of the current node (if any).
    • Every following item displays information about the children of the current item (if any).
    I've worked out the logic for populating the ListView in such a manner, but I encounter problems when trying to assign each individual list item a different layout xml file. I need to do this because the first item should display much more complex information than any other list item (eg an image, video, etc), and the parent item should display differently than the children (though not necessarily more complex). The children list items will display only 'meta' information (a few TextViews).

    Is this feasible, or should I simply put the information for the current item and parent item in a View separate from from the ListView?
     

    Advertisement
  2. Andrew McCandless

    Andrew McCandless Member This Topic's Starter

    Joined:
    Mar 8, 2010
    Messages:
    7
    Likes Received:
    0
    Okay, so I've worked out a solution. Basically I got the program working fine in my Adapter's getView() function, but I had some layout issues in one of my xml files. All good now :)
     
  3. tdieckman

    tdieckman Well-Known Member

    Joined:
    Sep 30, 2009
    Messages:
    49
    Likes Received:
    5
    If you ask a question, but then find a solution yourself, you would be a better forum member if you also shared the solution. In any case, good luck with your app.
     

Share This Page

Loading...