Empty list view from sqlite cursor?

Up vote 0 down vote favorite share g+ share fb share tw.

I have a sqlite with 5 record and I want to populate a list view with a cursor from this bbdd, but only create a list view with a white places, any places for a result of bddd query, without content. I think is for the textview color but no. Anyone can helps me?

Public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); setContentView(R.layout. Listatab); //Creamos la instancia de DataBaseHelper, un cursor y aplicamos el metodo getNombres al cursor.

Ayudabbdd = new DataBaseHelper(this); Cursor nombresC; nombresC = (Cursor) ayudabbdd.getNombres(); nombresC.moveToFirst(); startManagingCursor(nombresC); String datosRecibidos = new String {"nombre"}; int layoutDondeLoPongo = new int { R.layout. Entrada_lista}; //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){ SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout. Listatab, nombresC,datosRecibidos, layoutDondeLoPongo); this. SetListAdapter(adapter); this.getListView(); } Listatab.

Xml android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" > and entradalista. Xml android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" > android sqlite listview simplecursoradapter link|improve this question asked Dec 8 '11 at 13:09colymore266 46% accept rate.

Have you tried my answer.? Just replace it with your code and try it.. – user370305 Dec 8 '11 at 13:27 yes I try but don't work. – colymore Dec 8 '11 at 13:31 Look at my newly edited answer, Remove your code and put my code and try it.. Let me know what happen.. – user370305 Dec 9 '11 at 12:10 Same, all results is empty, but is the correct number of results – colymore Dec 9 '11 at 13:11.

Change this: int layoutDondeLoPongo = new int { R.layout. Entrada_lista}; String datosRecibidos = new String {"nombre"}; to: int layoutDondeLoPongo = new int { R.id. Nombre }; String datosRecibidos = new String {"son"}.

Same result if I change int layoutDondeLoPongo = new int { R.id. Nombre }; – colymore Dec 8 '11 at 13:22 Debug using nombresC.getCount() (should return 5), and nombresC.getColumnNames() (should return String {"nombre"}). If this is not the case, then it means your SQL query is wrong, or your result set doesn't have a column named nombre – Caner Dec 8 '11 at 13:31 Log.

E("debugeando", "son "+nombresC.getCount()); Log. E("debugeando", "son "+nombreC.getColumNames() It return 6 and son Ljava.lang. String;@4052ceb0 – colymore Dec 8 '11 at 13:36 I edited my answer, see the changes.

– Caner Dec 8 '11 at 13:43 Crash, son column doesn't exist – colymore Dec 8 '11 at 13:49.

Try this, EDIT:: super. OnCreate(savedInstanceState); setContentView(R.layout. Listatab); //Creamos la instancia de DataBaseHelper, un cursor y aplicamos el metodo getNombres al cursor.

Ayudabbdd = new DataBaseHelper(this); Cursor nombresC; nombresC = (Cursor) ayudabbdd.getNombres(); nombresC.moveToFirst(); startManagingCursor(nombresC); getListView(); ListAdapter adapter = new SimpleCursorAdapter(this,R.layout. Listatab,nombresC, new String {"nombre"}, new int { R.id. Nombre}); setListAdapter(adapter).

I don't know to saw the value of the cursor result – colymore Dec 8 '11 at 13:28 just nombresC.getCount(); Log. E("Size of cursor:",nombresC.getCount()); – user370305 Dec 8 '11 at 13:30 O, thanks I forget I have a log haha. I will try – colymore Dec 8 '11 at 13:32 Any new idea?

I will be crazy with this! – colymore Dec 9 '11 at 11:57.

I found the solution: listatab. Xml entrada_lista. Xml and the activity public void onCreate(Bundle savedInstanceState) { super.

OnCreate(savedInstanceState); setContentView(R.layout. Listatab); //Creamos la instancia de DataBaseHelper, un cursor y aplicamos el metodo getNombres al cursor. Ayudabbdd = new DataBaseHelper(this); Cursor nombresC; nombresC = (Cursor) ayudabbdd.getNombres(); nombresC.moveToFirst(); startManagingCursor(nombresC); String from = new String{DataBaseHelper.

CNOMBRE}; int to = new int{R.id. NombreLugar}; SimpleCursorAdapter lugares = new SimpleCursorAdapter(this, R.layout. Entrada_lista, nombresC, from, to); setListAdapter(lugares); }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions