title: Trouble refreshing android array adapter in fragment
body: <p>I'm having trouble refreshing an array adapter. When I'm testing the program on a phone it works well and refreshes perfectly when switching through fragments. The problem comes when I'm using a tablet and both fragments are up at once. </p>
  
  <p>Here's my fragment code:</p>
  
  <pre><code>public class HistoryFragment extends Fragment {
  
  private ArrayList&lt;String&gt; history = new ArrayList&lt;String&gt;();
  private ArrayAdapter&lt;String&gt; arrayAdapter;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      Bundle data = getArguments();
      // Inflate the layout for this fragment
      View v = inflater.inflate(R.layout.history, container, false);
      ListView view = (ListView) v.findViewById(R.id.list);
  
      if(data != null){
          history = data.getStringArrayList("history");
      }       
      arrayAdapter = new ArrayAdapter&lt;String&gt;(
              getActivity(), 
              android.R.layout.simple_list_item_1, history);
  
      view.setAdapter(arrayAdapter);
  
      return v;
  }
  
  public void setHistory(ArrayList&lt;String&gt; history) {
      history.addAll(history);
      arrayAdapter.notifyDataSetChanged();
  }
  
  }
  </code></pre>
  
  <p>Here's my activity code:</p>
  
  <pre><code>public class MainActivity extends Activity implements historyClickListener{
  
  public static ArrayList&lt;String&gt; history = new ArrayList&lt;String&gt;();
  
  CalcFragment mCalcFragment = new CalcFragment();
  HistoryFragment mHistFragment = new HistoryFragment();
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_main);
      if (findViewById(R.id.container) != null) {
          FragmentManager fragmentManager = getFragmentManager();
          FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  
          fragmentTransaction.add(R.id.container, mCalcFragment);
          fragmentTransaction.commit();
      }
  }
  
  @Override
  public void sendHistory(ArrayList&lt;String&gt; history){
      Fragment hf = getFragmentManager().findFragmentById(R.id.historyfrag);
  
      if(hf != null){
          mHistFragment.setHistory(history);
      }else{
          Bundle data = new Bundle();
          data.putStringArrayList("history", history);
          mHistFragment.setArguments(data);
          FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
          fragmentTransaction.replace(R.id.container, mHistFragment);
          fragmentTransaction.addToBackStack(null);
          fragmentTransaction.commit();
      }
  }
  </code></pre>
  
  <p>The sendHistory is an interface method in a calculator that help the calculator send the list of equations that have been done. Then in main activity if I'm using a tablet then all it does is setHistory which is a method in the history fragment. I believe the problem is that I'm not using <code>arrayAdapter.notifyDataSetChanged()</code> in the history fragment correctly. Can someone please help. Thanks!</p>