How To Delete all items In ListView using ArrayAdapter in Android
<p>I'm developing a Listview dynamically filled by a function that returns an ArrayAdapter which recieves a String parameter. This string parameter is the selected item of another dynamically filled Spinner.</p>

<p>When the function returns an ArrayAdapter with a number of items > 0, the Listview is sucessfully refreshed with the new items, but when the function returns 0 items on the ArrayAdapter, the listview doesn't clear the previous items. Here's the code I'm working on:</p>

<pre><code>ManifiestoSpinner = (Spinner) findViewById(R.id.spnManifiesto);
FacturasListview = (ListView) findViewById(R.id.lvwFacturas);

ManifiestoSpinner = (Spinner)
    ManifiestoSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {

            String EstadoID = EstadoSpinner.getSelectedItem().toString();
            ArrayList&lt;String&gt; ListManifiestos = (ArrayList&lt;String&gt;)Factura.GetManifiestosByEstado(EstadoID);

            ActualizarManifiestSpinner(manifiesto);

        }

        public void onNothingSelected(AdapterView&lt;?&gt; arg0) {

        }

private void ActualizarManifiestSpinner (ArrayList&lt;String&gt; manifiesto)
    {

    String[] datos = new String[manifiesto.size()];
    ArrayAdapter&lt;String&gt; AdapterManifiesto = new ArrayAdapter&lt;String&gt;(getApplicationContext(),
            android.R.layout.simple_spinner_dropdown_item, manifiesto.toArray(datos));

    ManifiestoSpinner.setAdapter(AdapterManifiesto);

}

ManifiestoSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {

            String Manifiesto = ManifiestoSpinner.getSelectedItem().toString();
            String Estado = EstadoSpinner.getSelectedItem().toString();
            fillData(Estado, Manifiesto);

            return;
        }

        public void onNothingSelected(AdapterView&lt;?&gt; arg0) {

        }

    });

private void fillData(String EstadoID, String ManifiestoID) {


    ArrayAdapter&lt;String&gt; adapter = (ArrayAdapter&lt;String&gt;) FacturasListview.getAdapter();

    if(adapter!= null)
    {
        adapter.clear();
        FacturasListview.setAdapter(adapter);
        FacturasListview.invalidateViews();
    }

    List&lt;String&gt; from = Factura.GetListClientesByEstadoManifiesto(EstadoID, ManifiestoID);

    adapter = new ArrayAdapter&lt;String&gt;(this,R.layout.factura_row, R.id.text1 ,from);
    FacturasListview.setAdapter(adapter);



}
</code></pre>

<p>When the List called from has from.size() = 0, the items previously show on the Listview are not cleared. </p>
