title: Fragment: Programmatically create view for xml to fill
body: <p>Is there a way to create a new layout that you can then have your XML inflate? </p>
  
  <pre><code>@Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle){
  
              one_third = (RelativeLayout)getActivity().findViewById(R.id.list3);
  
              DisplayMetrics dm = new DisplayMetrics();
              getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
              String width = "" + dm.widthPixels;
  
              int WIDTH;
              int SIZE;
  
              SIZE = Integer.parseInt(width.toString());
  
              WIDTH = (SIZE / 3); 
  
              one_third.setMinimumWidth(WIDTH);
  
      View homeselect = inflater.inflate(R.layout.listelements, container, false);
      setListAdapter(new ArrayAdapter&lt;String&gt;(getActivity(),
                  R.layout.start_row, R.id.label, views));
      return homeselect;
  
  }
  </code></pre>
  
  <p>I'm trying to take this bit of code in the fragment and here is where I want to have the new layout be created. I want to give it the <strong>width</strong> of the value <strong>WIDHT</strong> and then have my xml fill that. </p>