title: Android - best way to represent and traverse data in a tree structure
body: <p>I have an object that can be a parent or child of other objects.  It is representative of a client.  It looks like this</p>
  
  <pre><code>public class Site
  {
      public int SiteId;
      public List&lt;Site&gt; Children;
      public Site Parent;
  }
  </code></pre>
  
  <p>When <code>Parent</code> is null it is a top level or root object.  Not all objects have children. We impose no limit on how many levels down the sites can go. Our application is designed as such that Users and other data are tied to a particular site, whether it be a root or a child node anywhere in the tree.  For this reason I have to know the Site that the user is working with to pull back the correct data.</p>
  
  <p>My question is what is the best way to allow a user to traverse this tree?  There are a lot of nodes, so returning everything is not going to be desired.  Rather than returning all the children in my model object right now, I am instead simply returning a boolean value noting if the site has children.  Then when the user clicks on that option, my plan was to go get the children of that node, and show them for selection.</p>
  
  <p>I was thinking about using a <a href="http://developer.android.com/resources/tutorials/views/hello-listview.html" rel="nofollow"><code>ListView</code></a> in a similar fashion as most settings menus with an arrow shown if their are options.  I also looked at a <a href="http://developer.android.com/guide/topics/ui/menus.html" rel="nofollow"><code>Menu</code></a> but I'm just not sure the best way to do this.</p>