title: Android refresh a fragment list from its parent activity
body: <p>I have a main activity which contains the action bar with 3 menu buttons in it.</p>
  
  <p>I then have a fragment within this main activity which has a list.</p>
  
  <p>I would like to be able to refresh the list in the fragment from the main activity, when one of the menu buttons is clicked, or preferably just removed all the rows from the list.</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Thanks.</p>
  
  <pre><code>public class Favourite extends SherlockFragmentActivity {
  
      ActionBar actionBar;
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.favourite);
  
          actionBar = getSupportActionBar();
  
          actionBar.setDisplayShowTitleEnabled(false);
  
          BitmapDrawable bg = (BitmapDrawable)getResources().getDrawable(R.drawable.actionbar_bg);
          bg.setTileModeX(TileMode.REPEAT); 
          getSupportActionBar().setBackgroundDrawable(bg);
  
          getSupportActionBar().setIcon(R.drawable.favourite_title);
  
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
          ActionBar.Tab tabAll = actionBar.newTab();
          ActionBar.Tab tabfavs = actionBar.newTab();
          ActionBar.Tab tabhist = actionBar.newTab();
          tabAll.setText("all");
          tabfavs.setText("favs");
          tabhist.setText("hist");
          tabAll.setTabListener(new MyTabListener());
          tabfavs.setTabListener(new MyTabListener());
          tabhist.setTabListener(new MyTabListener());
          actionBar.addTab(tabAll);
          actionBar.addTab(tabfavs);
          actionBar.addTab(tabhist);
  
  
          try{
  
          }
          catch(Exception e)
          {
          }
      }
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
  
          MenuInflater inflater = getSupportMenuInflater();
          inflater.inflate(R.menu.actionbar_itemlist_favourite, menu);
  
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch(item.getItemId()) {
                  case R.id.history:
                      break;
                  case R.id.favourite:
                      Intent favAct = new Intent(this, Favourite.class);
                      startActivity(favAct);
                      break;
                  case R.id.delete:
                      ///I WANT TO BE ABLE TO REFRESH FRAGMENTLIST FROM HERE
                  }
                  return true;
      }
  
    }
  
  class MyTabListener implements ActionBar.TabListener {
  
      public void onTabSelected(Tab tab, FragmentTransaction ft) {
          if(tab.getPosition()==0)
          {
              FavouriteAllWords frag = new FavouriteAllWords();
              ft.replace(android.R.id.content, frag);
  
          }
          else if(tab.getPosition()==1)
          {
              FavouriteFavWords frag = new FavouriteFavWords();
              ft.replace(android.R.id.content, frag);
  
          }
          else if(tab.getPosition()==2)
          {
              FavouriteHistWords frag = new FavouriteHistWords();
              ft.replace(android.R.id.content, frag);
          }
      }
  
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {
          // TODO Auto-generated method stub
  
      }
  
      public void onTabReselected(Tab tab, FragmentTransaction ft) {
          // TODO Auto-generated method stub
  
      }
  
  }
  </code></pre>
  
  <p>////////////////////MY LIST FRAGMENT CLASS</p>
  
  <pre><code>public class FavouriteAllWords extends ListFragment {
  
      ArrayAdapter&lt;String&gt; adapter;
  
      List&lt;String&gt; stringOfFavWords;
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle saved)
      {   
          adapter = new ArrayAdapter&lt;String&gt;(  
                  inflater.getContext(), R.layout.row, stringOfFavWords);  
                  setListAdapter(adapter);  
  
          return super.onCreateView(inflater, group, saved);  
      }
  
      @Override
      public void onActivityCreated (Bundle savedInstanceState)
      {   
          super.onActivityCreated(savedInstanceState);
      }
  
  }
  </code></pre>