android - ArrayAdapter/ListView is not working -


I am doing new programming with Android, and my first action I did something wrong with the list here: Code: / P>

  cursor c = db.rawQuery ("select from contacts", blank); ArrayList & LT; String & gt; ListaArray = New Arrestist & lt; String & gt; (); ListView listadoContactos = (ListView) findViewById (R.id.listViewListaContactos); If (c.moveToFirst ()) {do {listaArray.add (c.getString (0)); } While (c.moveToNext ()); } // See a list of creams and un-ArrayAdapter & LT; String & gt; AdaptadorLista = New Array Adapter & lt; String & gt; (This, android.R.layout.simple_list_item_1, listaArray); ListadoContactos.setAdapter (adaptorLista);   

When I look at the results, it shows only the first item in the debug in my list that I ask. Can you help me, please?

Thanks in the advice! George.

PS: The "nombre" column is 0. This is why I am writing "getstring (0)", because I just want to show 1 column on each line.

  // Note the result in your query should be id-field, name "_id" cursor c = db.rawQuery ("selection Number, _id from contacts as nombre_id, tap); SimpleCursorAdapter Adapter List = New Simple Cursor Adapter (this, android.R.layout.simple_list_item_1, c, new string [] {"nombre"}, new int [] {android.R.id.text1}); ListadoContactos.setAdapter (adaptorLista);   

Here is a layout of each line in the android.R.layout.simple_list_item_1 list line, new string [] {"nombre"} The name of the field in the cursor, which is set to the text view in the LISTviewview line in the last argument, the specified text view ID new entry [] android.R.id.text1}

Comments