title: How to populate a fragment layout dynamically?
body: <p>I have a fragment with his class:</p>
  
  <pre><code>public class FormatShortFragment extends Fragment {
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
          View rootView = inflater.inflate(R.layout.bag_format_short, container, false);
  
          return rootView;
      }
  }
  </code></pre>
  
  <p>And this is his layout:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"&gt;
  
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>This fragment is shown by a FragmentPageAdapter.
  The layout will grow when an user add an item from server (the origin of the item doesn't matter), and this item will be an horizontal linearlayout, with textview and edittext (item_name, item_value). This value can be modifiable, so must be an edittext, also, this edittext will receive values periodically from server, so can be updated automatically.</p>
  
  <p>After explain this, how can I add this linearLayouts and his subviews to the GUI dynamically? and when should I update the interface?</p>
  
  <p>Thanks a lot, any help is good received, I'm really lost on this on this themes.</p>
  
  <p>EDITED WITH MODIFICATIONS:</p>
  
  <p>I have modified the code in this way:</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.bag_format_short, container, false);
  
      return rootView;
  }
  @Override
  public void onResume() {
      super.onResume();
      LinearLayout parentLinear = (LinearLayout) getActivity().findViewById(R.id.short_container);
      for (int i = 1; i&lt;10; i++ ){
          LinearLayout innerLinear = (LinearLayout) new LinearLayout(getActivity());
          TextView itemName = new TextView(getActivity());
          itemName.setText("Nombre");
          EditText itemValue = new EditText(getActivity());
          itemValue.setText("Valor");
          innerLinear.addView(itemName);
          innerLinear.addView(itemValue);
          parentLinear.addView(innerLinear);
      }
  }
  
  @Override
  public void onStart() {
      super.onStart();
  }
  
  @Override
  public void onStop() {
      super.onStop();
  }
  </code></pre>
  
  <p>And the fragment layout has been modified on this way:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"&gt;
  
  &lt;LinearLayout
      android:id="@+id/short_container"
      android:orientation="horizontal"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"&gt;
  &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Now the layout is growing in each for iteration.</p>
  
  <p>In this point i have another problems, I hope you can help me with this.
  - How can I generate a LayouParams object with attributes like gravity or weigth?
  - How can I pass data from MainActivity to the Fragment?
  - And how can i force the Fragment view to be raloaded with new data?</p>
  
  <p>Also i need to know how bind a clickListener event to programatically linearLayouts added, i need modify some values on server depending on the name and the edited value.</p>
  
  <p>Thanks a lot for this, you are saving my life. </p>