title: Android: ListFragment: How to refresh list
body: <p>I have a list view which is shown on a fragment. I have a button at the bottom of the screen in which when pressed, will call a webservice to reteive any additional data. If there is additional data, I need to add it to the list view. I have searched this forum and so many other web sites to try and find how to do it, but I have had no success. Any help is much appreciated. </p>
  
  <p>I am now thinking do I need to add the fragment dyncamically instead of having it defined on the following XML layout. </p>
  
  <p>I am using a ListFragment to inflate a list view on the screen. </p>
  
  <p>I have a screen with two fragments on it. The XML for the screen is below: -</p>
  
  <pre><code>&lt;LinearLayout 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:orientation="vertical" &gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="0dp"
          android:layout_weight="1"
          android:orientation="horizontal" &gt;
  
          &lt;fragment
              android:name="atos.mobilereporting.com.ReportList"
              android:layout_width="323dp"
              android:layout_height="match_parent" /&gt;
  
          &lt;fragment
              android:name="atos.mobilereporting.com.ReportDetail"
              android:layout_width="958dp"
              android:layout_height="match_parent" /&gt;
      &lt;/LinearLayout&gt;
  
  
      &lt;Button
          android:id="@+id/getReports"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Refresh Mobile Reports" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The code to inflate the view is below: -</p>
  
  <pre><code> public class ReportList extends ListFragment {
  
        public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
  
              // Get list of reports...
              repList = ReportDefinitionFactory.buildReportList(3);
  
              activity = getActivity();
  
              ListAdapter la = new ArrayAdapter&lt;String&gt;(getActivity(),
                      android.R.layout.simple_list_item_1,
                      ReportDefinitionFactory.getReportDescriptions(repList));
  
              setListAdapter(la);
  
          }
  
      }
  </code></pre>
  
  <p>This code shows a simple list view with 3 rows on it. </p>
  
  <p>It is at this point I must stop as I do not know were to go from here. I have the code which will add an additional row to the array that is used to initially build the list view, but I do not know how I can invoke a refresh on the list view. </p>
  
  <p>Thanks</p>
  
  <p>Martin</p>