title: Child Activity ListView updates Parent Activity's ListView
body: <p>I have a problem where the Child Activity's list view updates the content of the Parent Activity's List View.</p>
  
  <p>Basically, in my Parent Activity (DetailActivity) I have a List View called lvContacts which I populate with the following code:</p>
  
  <pre><code>ListView lvDetail = (ListView)findViewById(R.id.lvContacts);
  SingleLineAdapter adapter = new SingleLineAdapter(this, Items);
  lvDetail.setAdapter(adapter);
  lvDetail.setSelector(R.drawable.generic_selector);
  </code></pre>
  
  <p>Where Items is an ArrayList of GenericDataObject:</p>
  
  <pre><code>public class GenericDataObject implements Serializable {
  private static final long serialVersionUID = 7661717999129942666L;
  private String Id;
  private String Description;
  private String RawData;
  
  // getters and setters snipped for smaller code
  }
  </code></pre>
  
  <p>The SingleLineAdapter looks like this:</p>
  
  <pre><code>public class SingleLineAdapter extends CustomListAdapter implements Filterable {
  private static ArrayList&lt;GenericDataObject&gt; ObjectArray;
  private static ArrayList&lt;GenericDataObject&gt; OriginalArray;
  private LayoutInflater layoutInflater;
  private String SearchedText = "";
  private Context OriginatingContext;
  
  public SingleLineAdapter(Context context, ArrayList&lt;GenericDataObject&gt; Objects) {
      OriginatingContext = context;
      ObjectArray = Objects;
      OriginalArray = Objects;
      layoutInflater = LayoutInflater.from(context);
      if (Objects != null)
          Collections.sort(Objects, ObjectComparator);
  }
  
  private Comparator&lt;GenericDataObject&gt; ObjectComparator = new Comparator&lt;GenericDataObject&gt;() {
      @Override
      public int compare(GenericDataObject object1,
              GenericDataObject object2) {
          return object1.getDescription().compareTo(object2.getDescription());
      }
  };
  
  @Override
  public int getCount() {
      return ObjectArray.size();
  }
  
  @Override
  public Object getItem(int position) {
      return ObjectArray.get(position);
  }
  
  @Override
  public long getItemId(int position) {
      return position;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder;
      if (convertView == null) {
          convertView = layoutInflater.inflate(R.layout.listitem_generic, null);
             holder = new ViewHolder();
             holder.lblTitle = (TextView)convertView.findViewById(R.id.lblTitle);
  
             convertView.setTag(holder);
            } else {
             holder = (ViewHolder) convertView.getTag();
      }
  
      holder.lblTitle.setText(ObjectArray.get(position).getDescription(), TextView.BufferType.SPANNABLE);
  
      if (!SearchedText.equals("")) {
          Spannable wordToSpan = (Spannable)holder.lblTitle.getText();
          String[] comps;
          if (SearchedText.startsWith("\""))
              comps = new String[] { SearchedText.substring(1, SearchedText.length() - 1) };
          else
              comps = SearchedText.split(" ");
  
          String name = holder.lblTitle.getText().toString().toLowerCase();
          for(int i = 0; i &lt; comps.length; i++) {
              int Start = name.indexOf(comps[i]);
              while (Start &gt; -1) {
                  int End = Start + comps[i].length();
                  wordToSpan.setSpan(new BackgroundColorSpan(0xFFFF9900), Start, End, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                  Start = name.indexOf(comps[i], End);
              }
          }
      }
      setFont(holder.lblTitle);
  
      return convertView;
  }
  
  static class ViewHolder {
      TextView lblTitle;
  }
  
  @Override
  public Filter getFilter() {
      return new Filter() {
  
          @Override
          protected FilterResults performFiltering(CharSequence constraint) {
              SearchedText = constraint.toString();
              final FilterResults result = new FilterResults();
  
              final ArrayList&lt;GenericDataObject&gt; custs = new ArrayList&lt;GenericDataObject&gt;();
              if(constraint != null) {
                  String[] searches;
                  if (constraint.toString().startsWith("\"") &amp;&amp; constraint.toString().endsWith("\""))
                      searches = new String[] { SearchedText.substring(1, SearchedText.length() - 1) };
                  else
                      searches = constraint.toString().split(" ");
                  for(int i = 0; i &lt; OriginalArray.size(); i++) {
                      String customerName = OriginalArray.get(i).getDescription().toLowerCase();
  
                      boolean bNotFound = false;
                      for(int j = 0; j &lt; searches.length &amp;&amp; bNotFound == false; j++) {
                          String searchFor = searches[j];
                          if (!customerName.contains(searchFor))
                              bNotFound = true;
                      }
  
                      if (!bNotFound)
                      {
                          custs.add(OriginalArray.get(i));
                      }
                  }
                  result.values = custs;
              }
              return result;
          }
  
          @Override
          @SuppressWarnings("unchecked")
          protected void publishResults(CharSequence constraint,
                  FilterResults results) {
              ObjectArray = (ArrayList&lt;GenericDataObject&gt;)results.values;
              notifyDataSetChanged();
          }
      };
  }
  }
  </code></pre>
  
  <p>The OnItemClick for lvContacts queries for data on a web service then shows a new Activity:</p>
  
  <pre><code>Intent detail = new Intent(DetailActivity.this, ContactDetailActivity.class);
  detail.putExtra("ListOfDetails", RowsFromService);
  startActivity(detail);
  </code></pre>
  
  <p>The RowsFromService is an ArrayList of GenericDataObject as well.</p>
  
  <p>In the ContactDetailActivity, I have a ListView called lvContactDetail. I populate this by:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      ArrayList&lt;GenericDataObject&gt; DetailRows = (ArrayList&lt;GenericDataObject&gt;)getIntent().getExtras().getSerializable("ListOfDetails");
      ListView lvContactDetail = (ListView)findViewById(R.id.lvContactDetail);
      SingleLineAdapter detailAdapter = new SingleLineAdapter(this, DetailRows);
      lvContactDetail.setAdapter(detailAdapter);
      lvContactDetail.setSelector(R.drawable.generic_selector);
  }
  </code></pre>
  
  <p>Everything up to this point works perfectly, but if I go back to the DetailActivity (Parent Activity) using the back button or even activity.finish() on a button, the original list (lvContacts) is now populated with the results of lvContactDetail.</p>
  
  <p>This only happens with two lists in my app, all the rest are working 100% correctly.</p>
  
  <p>Is there any special precautions to take note of when loading lists from other lists? It's worth noting that the main activity in my app sets flags for CLEAR_TOP and REORDER_TO_FRONT...</p>
  
  <p>Strange enough: Even if I comment out the setAdapter line in the child activity, the parent activity is STILL being updated with the other activity's data. Can this be related to creating a new instance of SingleLineAdapter? </p>