1. Check out our companion app, Forums for Android! Download from Google Play

Multiple List-Item Layouts in One ListView

Discussion in 'Application Development' started by Andrew McCandless, Apr 18, 2010.

  1. Andrew McCandless

    Thread Starter
    25

    Mar 8, 2010
    7
    0
    25
    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

    Thread Starter
    25

    Mar 8, 2010
    7
    0
    25
    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
    16

    Sep 30, 2009
    49
    5
    16
    San Francisco, CA
    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...