android.widget.ListView is not a view that can be bounds by this SimpleCursorAdapter
-
29-10-2019 - |
Question
Im trying to get some data from bbdd with this method
/**********************************************************************
* * Obten todos los nombres
*
*/
public Cursor getNombres(){
Cursor respuesta = db.rawQuery("select "+TABLE_ROW_ID+","+CNOMBRE+" from "+TABLE_NAME, null);
return respuesta;
}
in this class
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Creamos la instancia de DataBaseHelper, un cursor y aplicamos el metodo getNombres al cursor.
ayudabbdd = new DataBaseHelper(this);
Cursor nombresC;
nombresC = (Cursor) ayudabbdd.getNombres();
startManagingCursor(nombresC);
//Mientras el cursor no este vacio rellenamos la lista con el adaptador, que nos sirve para conectar unos datos con el listview.
if(nombresC!=null){
ListAdapter adapter = new SimpleCursorAdapter(this, R.layout.listatab, nombresC, new String[] { "nombre" }, new int[] { R.id.lista });
this.setListAdapter(adapter);
this.getListView().setTextFilterEnabled(true);
}
}
But log cat return me that
android.widget.ListView is not a view that can be bounds by this SimpleCursorAdapter
But in some tutorials this is the way to get an array from a bbdd and they don't have problem
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow