title: call notifyondatasetchanged() from another adapter
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4754208/is-there-a-way-to-call-notifydatasetchanged-from-the-main-activity-for-a-custom">Is there a way to call notifyDataSetChanged() from the main activity for a custom adapter of an item inside another custom adapter?</a>  </p>
  </blockquote>
  
  
  
  <p>i have two listarray adapters A and B. 'A' contains few buttons that when clicked should process the data present in 'B' and then notify adapter 'B' that some change has occurred so that 'B' refreshes itself and displays new data. 
  I see that this issue was asked earlier <a href="https://stackoverflow.com/questions/4754208/is-there-a-way-to-call-notifydatasetchanged-from-the-main-activity-for-a-custom">here</a> in SO. But the solution does not provide adequate information.</p>
  
  <p>Thank you for the solution... I tried implementing this but it does not recognize which button was pressed (it considers the entire list as one entity). Also, it does not update the list content as well even though I tried keeping a default sort</p>
  
  <pre><code>    headerListView.setOnItemClickListener(new OnItemClickListener() {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; arg0, View v, int arg2,
                      long arg3) {
                  sorter = new TwoWaySorter();
                  Message msg = new Message();
  
                  Log.i("Click","arg0.getId():"+arg0.getId());
                  Log.i("Click", v.getId() + " id is " + v.toString());
                  Log.i("Click","arg2:"+arg2+" arg3:"+arg3);
                  switch (v.getId()) {
  
                  case R.id.headerList_quantity: // perform sort over the quantity
                      Log.i("Click", "qty clicked");
                      System.out.println("..Item is clicked..");
                      msg.what = UPDATE_QTY;
                      updateListHandler.sendMessage(msg);
                      //sorter.sortBasedOn(contentList, "symQty");
                      //contentAdapter.notifyDataSetChanged();
                      break;
                  case R.id.headerList_price: // perform sort over price
                      Log.i("Click", "list price clicked");
                      msg.what = UPDATE_PRICE;
                      updateListHandler.sendMessage(msg);
  
                      //sorter.sortBasedOn(contentList, "price");
                      //contentAdapter.notifyDataSetChanged();
  
                      break;
  }
  }});
  
  
   private Handler updateListHandler = new Handler() {
              @Override
              public void handleMessage(Message msg) {
                  switch (msg.what) {
                  case UPDATE_LIST:
                      sorter = new TwoWaySorter();
                      Log.i("Click", "sort based on priceYesterday");
                      sorter.sortBasedOn(contentList, "priceYesterday");
                      contentAdapter.notifyDataSetChanged();
                      break;
  
                  }
  
              }};
  </code></pre>
  
  <p>Also, just in case you wanted to see the Adapter. Please note that the TextView are set to setClickable="true"</p>
  
  <pre><code>public class HeaderAdapter extends ArrayAdapter&lt;Header&gt;  {
  final Header[] listSymbols;
  private TwoWaySorter sorter;
  private Vector&lt;Content&gt; contentList;
  //private ArrayAdapter&lt;Content&gt; contentAdapter;
  
  public HeaderAdapter(Context context, int symResourceID, Header[] objects,
          Vector&lt;Content&gt; contentList, ArrayAdapter&lt;Content&gt; contentAdapter) {
      super(context, symResourceID, objects);
      listSymbols = objects;
      sorter = new TwoWaySorter();
      this.contentList = contentList;
      //this.contentAdapter = contentAdapter;
  
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      View row = convertView;
      if (row == null) {
          LayoutInflater inflater = (LayoutInflater) getContext()
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          row = inflater.inflate(R.layout.twoway_header_right, parent, false);
      }
      Header headerRec = listSymbols[position];
  
      TextView symQty = (TextView) row.findViewById(R.id.headerList_quantity);
      symQty.setText("" + headerRec.symQty);
      Log.i("Click","symQty id"+symQty.getId());
      //symQty.setOnClickListener(this);
  
      TextView symPx = (TextView) row.findViewById(R.id.headerList_price);
      symPx.setText("" + headerRec.price);
      Log.i("Click","symPx id"+symPx.getId());
      //symPx.setOnClickListener(this);
  
      TextView symPxC = (TextView) row
              .findViewById(R.id.headerList_priceChange);
      symPxC.setText("" + headerRec.priceYesterday);
  //  symPxC.setOnClickListener(this);
  
      TextView symVal = (TextView) row.findViewById(R.id.headerList_value);
      symVal.setText("" + headerRec.daysGain);
  //  symVal.setOnClickListener(this);
  
      TextView symValC = (TextView) row
              .findViewById(R.id.headerList_valueChange);
      symValC.setText("" + headerRec.daysGainPercent);
  //  symQty.setOnClickListener(this);
  
      TextView symValCP = (TextView) row
              .findViewById(R.id.headerList_valueChangePercent);
      symValCP.setText("" + headerRec.change);
  //  symQty.setOnClickListener(this);
  
      TextView symQuote = (TextView) row.findViewById(R.id.headerList_quote);
      symQuote.setText("" + headerRec.week52High);
  //  symQty.setOnClickListener(this);
  
      row.setBackgroundColor(R.color.light_gray);
      return row;
  }
  
  /*@Override
  public void onClick(View v) {
      Log.i("Click", v.getId() + " " + v.toString());
      switch (v.getId()) {
  
      case R.id.headerList_quantity: // perform sort over the quantity
          Log.i("Click", "qty clicked");
          sorter.sortBasedOn(contentList, "symQty");
          MainActivity.contentAdapter.notifyDataSetChanged();
          break;
      case R.id.headerList_price: // perform sort over price
          Log.i("Click", "list price clicked");
  
          sorter.sortBasedOn(contentList, "price");
          MainActivity.contentAdapter.notifyDataSetChanged();
  
          break;
      case R.id.headerList_priceChange: // perform sort over price change
          sorter.sortBasedOn(contentList, "priceYesterday");
          MainActivity.contentAdapter.notifyDataSetChanged();
  
          Log.i("Click", "price change clicked");
  
          break;
      case R.id.headerList_value:
          Log.i("Click", "list value clicked");
  
          sorter.sortBasedOn(contentList, "change");
          MainActivity.contentAdapter.notifyDataSetChanged();
  
          break;
      case R.id.headerList_valueChange:
          Log.i("Click", "value change clicked");
  
          sorter.sortBasedOn(contentList, "daysGain");
          MainActivity.contentAdapter.notifyDataSetChanged();
  
          break;
      case R.id.headerList_valueChangePercent:
          Log.i("Click", "change percent clicked");
  
          sorter.sortBasedOn(contentList, "daysGainPercent");
          MainActivity.contentAdapter.notifyDataSetChanged();
  
          break;
      case R.id.headerList_quote:
          Log.i("Click", "return clicked");
  
          sorter.sortBasedOn(contentList, "returns");
          MainActivity.contentAdapter.notifyDataSetChanged();
  
          break;
      //}
  </code></pre>
  
  <p>*/  //}
  }</p>