title: Building a Dashboard Layout as Fragment programmatically
body: <p>I'm building my first Android app, main view and all subviews are based on a dashboard layout so I'm trying to reuse the DashboardLayout from the GoogleIO 2011.</p>
  
  <p>I managed to get it working with the <code>ViewPager</code> using <code>FragmentPagerAdapter</code> (since <code>DashboardLayout</code> is designed as Fragment). I created three xml as <code>DashboardLayout</code> with 6 icons each and works perfectly.</p>
  
  <p>Now it's time to make everything dynamic: I need to create <code>DashboardLayout</code>s programmatically according to remote data (json).</p>
  
  <p>At the moment I'm calling the instantiation of the <code>DashboardFragment</code> in the main activity like this:</p>
  
  <pre><code>...
  
  ArrayList&lt;Fragment&gt; fragments = new ArrayList&lt;Fragment&gt;();
  fragments.add(Fragment.instantiate(this, DashboardFragment.class.getName()));
  
  ...
  </code></pre>
  
  <p>in the <code>DashboardFragment</code> class I have:</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
       return inflater.inflate(R.layout.fragment_dashboard, container, false);
  }
  </code></pre>
  
  <p>and basically this is the fragment_dashboard xml file:</p>
  
  <pre><code>&lt;com.google.android.ui.widget.DashboardLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
  
      &lt;Button android:id="@+id/firstbutton"
          style="@style/DashboardButton"
          android:text="@string/btn_first"
          android:drawableTop="@drawable/btn_first" /&gt;
      ...
  &lt;/com.google.android.widget.DashboardLayout&gt;
  </code></pre>
  
  <p>Now instead of returning fragment_dashboard inflated view I think I need to Instantiate DashboardLayout and add to it buttons according to the downloaded json data. But I don't know how.</p>
  
  <p>Ideas?</p>