Skip to content Skip to sidebar Skip to footer

Android.widget.listview Is Not A View That Can Be Bounds By This Simplecursoradapter

Im trying to get some data from bbdd with this method /********************************************************************** * * Obten todos los nombres * */ public Cursor ge

Solution 1:

If you read the doc for SimpleCursorAdapter, the constructor, which by the way is deprecated, gets as 5th parameter the ids of TextViews, from the doc:

to->    The views that should display columnin the "from" parameter. 
These should all be TextViews. The first N views in this list are 
given the valuesof the first N columns in the from parameter. 
Can be null if the cursorisnot available yet.

Instead you are giving the id of lista, which is a ListView. Try to change using this:

int[] to = newint[] { android.R.layout.simple_list_item_1 };
...
SimpleCursorAdapter adapter = newSimpleCursorAdapter(this, R.layout.listatab, nombresC, new String[] { "nombre" }, to);

En plus, if your activity extends ListActivity, the ListView in your xml must have this id:

android:id="@android:id/android:list"

Take a look to this example.

Post a Comment for "Android.widget.listview Is Not A View That Can Be Bounds By This Simplecursoradapter"