E Ennesima77 Member Licensed User Longtime User Jul 9, 2012 #1 Ciao a tutti, sono un neofita che più neofita non si può, anche se conosco qualcosaina di Visual Basic dalla versione 6 alla .net. Ho iniziato a smacchinare con Basic4Android e volevo riempire una ListView con dati prelevati direttamente da una chiamata SQL. A tale scopo ho usato questa sintarsi: DBUtils.ExecuteListView(SQLDB,"select FullName, PlayerID from players",Null,0,lwPlayers,False) e funziona correttamente, il problema che io vorrei reperire il PlayerID dalla ListView, ma se vado in ListView_Click il Value è restituito un valore strano che non riesco ad interpretare. Avevo trovato un treath che ne parlava in inglese, ma non c'era risposta. Riuscite ad aiutarmi?:sign0085: Grazie e buona giornata.
Ciao a tutti, sono un neofita che più neofita non si può, anche se conosco qualcosaina di Visual Basic dalla versione 6 alla .net. Ho iniziato a smacchinare con Basic4Android e volevo riempire una ListView con dati prelevati direttamente da una chiamata SQL. A tale scopo ho usato questa sintarsi: DBUtils.ExecuteListView(SQLDB,"select FullName, PlayerID from players",Null,0,lwPlayers,False) e funziona correttamente, il problema che io vorrei reperire il PlayerID dalla ListView, ma se vado in ListView_Click il Value è restituito un valore strano che non riesco ad interpretare. Avevo trovato un treath che ne parlava in inglese, ma non c'era risposta. Riuscite ad aiutarmi?:sign0085: Grazie e buona giornata.
maxware Well-Known Member Licensed User Longtime User Jul 9, 2012 #2 Ciao Ennesima77 posta il codice che gli diamo un cuc dovrebbe essere cosi Sub lstDoc_ItemClick (Position As Int, Value As Object) valore=lstDoc.GetItem(Position) End Sub ciaooooooo Mamo
Ciao Ennesima77 posta il codice che gli diamo un cuc dovrebbe essere cosi Sub lstDoc_ItemClick (Position As Int, Value As Object) valore=lstDoc.GetItem(Position) End Sub ciaooooooo Mamo
E Ennesima77 Member Licensed User Longtime User Jul 10, 2012 #3 in Activity_Create ho inserito questo: SQLDB.Initialize(File.DirDefaultExternal,"FlorManager.sqlite",False) DBUtils.ExecuteListView(SQLDB,"select FullName, PlayerID from players",Null,0,lwPlayers,False) ed ho aggiunto il seguente codice: Sub lwPlayers_ItemClick (Position As Int, Value As Object) Msgbox(lwPlayers.GetItem(Position),"Valore") 'Msgbox(Value(0) & CRLF & Value(1) & CRLF & Position,"Testo") End Sub il risultato ottenuto è quello in allegato, ma seconda riga non viene compilata in quanto mi dà una serie di errori. Attachments Nuova immagine bitmap.jpg 74.9 KB · Views: 528
in Activity_Create ho inserito questo: SQLDB.Initialize(File.DirDefaultExternal,"FlorManager.sqlite",False) DBUtils.ExecuteListView(SQLDB,"select FullName, PlayerID from players",Null,0,lwPlayers,False) ed ho aggiunto il seguente codice: Sub lwPlayers_ItemClick (Position As Int, Value As Object) Msgbox(lwPlayers.GetItem(Position),"Valore") 'Msgbox(Value(0) & CRLF & Value(1) & CRLF & Position,"Testo") End Sub il risultato ottenuto è quello in allegato, ma seconda riga non viene compilata in quanto mi dà una serie di errori.
klaus Expert Licensed User Longtime User Jul 10, 2012 #4 Try following code: Code: Copy DBUtils.ExecuteListView(SQLDB,"select PlayerID, FullName from players", Null, 0, lwPlayers, True) You must set the last parameter to True for two lines ListView. Swap FullName and PlayerID to have the PlayerID in the first line as the return value. And Code: Copy Sub lwPlayers_ItemClick (Position As Int, Value As Object) Msgbox(lwPlayers.Value, "Valore") End Sub Sorry, it's in english. Best regards.
Try following code: Code: Copy DBUtils.ExecuteListView(SQLDB,"select PlayerID, FullName from players", Null, 0, lwPlayers, True) You must set the last parameter to True for two lines ListView. Swap FullName and PlayerID to have the PlayerID in the first line as the return value. And Code: Copy Sub lwPlayers_ItemClick (Position As Int, Value As Object) Msgbox(lwPlayers.Value, "Valore") End Sub Sorry, it's in english. Best regards.
E Ennesima77 Member Licensed User Longtime User Jul 10, 2012 #5 No problem, it's useful for me also in english. I'm not write English very well, but I use to read a lot of manual and 95% it's clear for me. I tryed your code, but same result. Just one treath talk about this topis http://www.b4x.com/forum/basic4andr...434-sqllite-listview-selection.html#post81769 but there isn't the answer from artiechappie. I hope some one can help me.
No problem, it's useful for me also in english. I'm not write English very well, but I use to read a lot of manual and 95% it's clear for me. I tryed your code, but same result. Just one treath talk about this topis http://www.b4x.com/forum/basic4andr...434-sqllite-listview-selection.html#post81769 but there isn't the answer from artiechappie. I hope some one can help me.
klaus Expert Licensed User Longtime User Jul 10, 2012 #6 Sorry, I didn't look carefully enough. DBUtils uses AddTwoLines2 so the return value is an Object. The codes below work: Code: Copy DBUtils.ExecuteListView(SQLDB,"select FullName, PlayerID from players", Null, 0, lwPlayers, True) Code: Copy Sub lwPlayers_ItemClick (Position As Int, Value As Object) Dim Valore(2) As String Valore = Value Msgbox(Valore(0) & " " & Valore(1), "Valore") End Sub I tried a similar code as the one posted and got the same problem, so I looked deeper inside. Best regards.
Sorry, I didn't look carefully enough. DBUtils uses AddTwoLines2 so the return value is an Object. The codes below work: Code: Copy DBUtils.ExecuteListView(SQLDB,"select FullName, PlayerID from players", Null, 0, lwPlayers, True) Code: Copy Sub lwPlayers_ItemClick (Position As Int, Value As Object) Dim Valore(2) As String Valore = Value Msgbox(Valore(0) & " " & Valore(1), "Valore") End Sub I tried a similar code as the one posted and got the same problem, so I looked deeper inside. Best regards.
E Ennesima77 Member Licensed User Longtime User Jul 22, 2012 #8 Giusto un'altra curiosità. Nel progetto ho aggiunto file SQLLite, che però non si aggiorna! Mi spiego meglio: se faccio delle modifiche nel DB (uso SQLLite Manager di Firefox) il file non viene poi riportato nel dispositivo e rimane il vecchio. Per il momento l'ho copiato a manina, ma esiste un modo per far vedere in automatico l'aggiornamento del file? I try to translateit best as I can. In my project I had add an SQLLite file. I use SQLLite Manager in Mozzilla Firefox to manage and edit the file (add column, new table, etc.) When I do any kind of edit it doesn't update in the device, and use always old version. I tried to delete and then attach again the file from "File panell" but it doesn' work. Any Idea???? Thanks
Giusto un'altra curiosità. Nel progetto ho aggiunto file SQLLite, che però non si aggiorna! Mi spiego meglio: se faccio delle modifiche nel DB (uso SQLLite Manager di Firefox) il file non viene poi riportato nel dispositivo e rimane il vecchio. Per il momento l'ho copiato a manina, ma esiste un modo per far vedere in automatico l'aggiornamento del file? I try to translateit best as I can. In my project I had add an SQLLite file. I use SQLLite Manager in Mozzilla Firefox to manage and edit the file (add column, new table, etc.) When I do any kind of edit it doesn't update in the device, and use always old version. I tried to delete and then attach again the file from "File panell" but it doesn' work. Any Idea???? Thanks
klaus Expert Licensed User Longtime User Jul 22, 2012 #9 Without seeing your code it's impossible to help you. We need to know what you have done and how. Best regards.
Without seeing your code it's impossible to help you. We need to know what you have done and how. Best regards.
E Ennesima77 Member Licensed User Longtime User Jul 23, 2012 #10 I don't use any particular code, just a activity_create I have had DBUtils.CopyDBFromAssets("FlorManager.sqlite") to pickup the db from the project. In the attachment you can see also the file in mty project. Last edited: Jul 23, 2012
I don't use any particular code, just a activity_create I have had DBUtils.CopyDBFromAssets("FlorManager.sqlite") to pickup the db from the project. In the attachment you can see also the file in mty project.
klaus Expert Licensed User Longtime User Jul 23, 2012 #11 Do you test if the file already exists on the SD card? If no every time you run the program you copy the DB from DirAssets. Did you have a look at chapter 5 in the User's Guide especialy page 20 ? In the code example from page 20 you can replace File.Copy(File.DirAssets, DBFileName, DBFileDir, DBFileName) by DBUtils.CopyDBFromAssets("FlorManager.sqlite") You must also adapt the variables to your project. Best regards.
Do you test if the file already exists on the SD card? If no every time you run the program you copy the DB from DirAssets. Did you have a look at chapter 5 in the User's Guide especialy page 20 ? In the code example from page 20 you can replace File.Copy(File.DirAssets, DBFileName, DBFileDir, DBFileName) by DBUtils.CopyDBFromAssets("FlorManager.sqlite") You must also adapt the variables to your project. Best regards.
E Ennesima77 Member Licensed User Longtime User Jul 25, 2012 #12 I try to use the code in capter 5, but I need to delete manully the file from the device to update it. It's not a big problem. Thanks a lot for you reply.
I try to use the code in capter 5, but I need to delete manully the file from the device to update it. It's not a big problem. Thanks a lot for you reply.