title: My ListView adapter doesn't update
body: <p>I have a Dialog where the user select a option and change de adapter, the problem is that the adapter doesn't update, I'm calling a function that returns a <code>ItemAdapter</code> and then I update my adapter like this  <code>setListAdapter(newOne);</code> and it doesn't update, here is the complete code</p>
  
  <pre><code>public class MyActivity extends ListActivity {
  
  char[] items = { 'e', 'f', 'f', 'f', 'e', 'f', 'e', 'e', 'f', 'f', 'e', 'e', 'f', 'f', 'f', 'e', 'e', 'f', 'f', 'e', 'e', 'f', 'f', 'f', 'e', 'e', 'f', 'f', 'e', 'e', 'f', 'f', 'f', 'e', 'e', 'f', 'f', 'p', 'e', 'e', 'p', 'f', 'f', 'f', 'e', 'e', 'a', 'f', 'p', 'f', 'e', 'e', 'f', 'f', 'p', 'f', 'e', 'a', 'e', 'p', 'f', 'f', 'e', 'p', 'e', 'f', 'f', 'f', 'a', 'p', 'e', 'e', 'p', 'f', 'f', 'e', 'p', 'e', 'f', 'p', 'f', 'e', 'f', 'e', 'f' };
  int[] horas =   {00, 01, 03, 04, 04, 05, 05, 05, 06, 06, 06, 06, 07, 07, 07, 07, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 21, 21, 21, 22, 22, 23, 23,};
  int[] minutos = {20, 00, 00, 00, 30, 10, 25, 40, 10, 20, 40, 50, 00, 10, 30, 50, 00, 20, 40, 00, 10, 20, 30, 50, 10, 20, 40, 00, 20, 30, 40, 50, 10, 30, 40, 10, 20, 30, 40, 50, 00, 00, 10, 30, 50, 00, 10, 20, 30, 40, 00, 10, 30, 50, 50, 00, 10, 20, 20, 30, 40, 00, 20, 30, 30, 50, 10, 20, 20, 30, 30, 40, 50, 00, 20, 40, 50, 50, 10, 15, 30, 00, 40, 10, 50};
  String[] total = new String[horas.length];
  String[] tipos = {"Etacer", "Fluviales", "Fluviales al pozo", "Fluviales a abogacia"};
  
  // declare class variables
  private ArrayList&lt;Item&gt; m_parts = new ArrayList&lt;Item&gt;();
  private Runnable viewParts;
  private ItemAdapter m_adapter;
  
  /** Called when the activity is first created. */
  public void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_my);
  
      for (int i = 0; i &lt; items.length; i++) {
          total[i] = String.format("%02d",horas[i]) + ":" + String.format("%02d",minutos[i]);
      }
  
      int cuantos_f = cuantosF('f');
  
      // instantiate our ItemAdapter class
      m_adapter = new ItemAdapter(this, R.layout.row, m_parts);
  
      for (int i = 0; i &lt; items.length; i++) {
          m_parts.add(new Item(horas[i], minutos[i], items[i], total[i]));
      }
  
      m_adapter = new ItemAdapter(MyActivity.this, R.layout.row, m_parts);
  
      // display the list.
      setListAdapter(m_adapter);
  
      RippleView mButton = (RippleView) findViewById(R.id.btn);
      final RippleView filtrar = (RippleView) findViewById(R.id.filtrar);
      filtrar.setRippleColor(Color.parseColor("#2ecc71"), 0.8f);
      mButton.setRippleColor(Color.parseColor("#2ecc71"), 0.8f);
      mButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              //your code
  
              mostrarSiguiente();
          }
      });
  
      filtrar.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              AlertDialog.Builder builder = new AlertDialog.Builder(MyActivity.this);
              builder.setTitle("Pick a color");
              builder.setItems(tipos, new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                      ItemAdapter newOne = filtrar_tipo(which);
                      setListAdapter(newOne);  // Here it should update
                  }
              });
              builder.show();
          }
      });
  
      final Handler mHandler = new Handler();
      new Thread(new Runnable() {
          @Override
          public void run() {
              // TODO Auto-generated method stub
              while (true) {
                  try {
                      Thread.sleep(1000);
                      mHandler.post(new Runnable() {
  
                          @Override
                          public void run() {
                              // TODO Auto-generated method stub
                              // Write your code here to update the UI.
                              m_adapter.notifyDataSetChanged();
                          }
                      });
                  } catch (Exception e) {
                      // TODO: handle exception
                  }
              }
          }
      }).start();
  
  }
  
  private ItemAdapter filtrar_tipo(int i) {
      /* 0 etacer - 1 Fluvales - 2 fluviales al pozo - 3 fluv abogacia  */
  
      ItemAdapter adapter;
  
      char letra = 'g';
      int contador;
      switch (i){
          case 0: letra = 'e'; break;
          case 1: letra = 'f'; break;
          case 2: letra = 'p'; break;
          case 3: letra = 'a'; break;
      }
      contador = cuantosF(letra);
  
      Log.e("Contador", String.valueOf(contador));
      ArrayList&lt;Integer&gt; minutosf = new ArrayList&lt;Integer&gt;();
      ArrayList&lt;Integer&gt; horasf = new ArrayList&lt;Integer&gt;();
      ArrayList&lt;String&gt; fin = new ArrayList&lt;String&gt;();
      ArrayList&lt;Character&gt; letras = new ArrayList&lt;Character&gt;();
  
  
      for (int h = 0; h &lt; contador; h++) {
          minutosf.add(h,minutos[h]);
          horasf.add(h,horas[h]);
          letras.add(h,items[h]);
      }
      int[] minutosFinales = aArray(minutosf);
      int[] horasFinales = aArray(horasf);
  
      for (int y = 0; y &lt; contador; y++) {
          fin.add(String.format("%02d",horasFinales[y]) + ":" + String.format("%02d",minutosFinales[y]));
      }
      String[] listaFinal = fin.toArray(new String[fin.size()]);
  
  
      adapter = new ItemAdapter(this, R.layout.row, m_parts);
  
      for (int t = 0; t &lt; contador; t++) {
          m_parts.add(new Item(horasFinales[t], minutosFinales[t], letra, listaFinal[t]));
      }
  
      adapter = new ItemAdapter(MyActivity.this, R.layout.row, m_parts);
  
      // display the list.
      return adapter;
  }
  
  private int cuantosF(char mi_char) {
      int contador = 0;
      for (int j = 0; j &lt; items.length; j++) {
          if (items[j] == mi_char){
              contador++;
          }
      }
      return contador;
  }
  
  private int[] aArray(List&lt;Integer&gt; integers) {
      int[] ints = new int[integers.size()];
      int i = 0;
      for (Integer n : integers) {
          ints[i++] = n;
      }
      return ints;
  }
  
  private void mostrarSiguiente() {
  
      Calendar rightNow = Calendar.getInstance();
      int hour = rightNow.get(Calendar.HOUR_OF_DAY);
      int min = rightNow.get(Calendar.MINUTE);
  
      int mejor_pos = 999, menor_resta = 1500;
  
      for (int i = 0; i &lt; horas.length; i++) {
          if((horas[i]*60 + minutos[i] - (hour*60+min)) &gt; 0){
              if ((horas[i]*60 + minutos[i] - (hour*60+min)) &lt; menor_resta){
                  mejor_pos = i;
                  menor_resta = (horas[i]*60 + minutos[i] - (hour*60+min));
              }
          }
      }
  
      ListView lv = getListView();
      lv.smoothScrollToPosition(mejor_pos);
  }
  }
  </code></pre>
  
  <p>If anyone could help me it will make me happy :)</p>
  
  <p>Thanks in advanced</p>