Sub EventNamexclv_ItemClick (Index As Int, Value As Object) Dim id As = Value End Sub
Private Sub EventNamexclv_ItemClick (Index As Int, Value As Object)
Dim id As String = Value
Log(id)
End Sub
Private Sub xclv_ItemClick (Index As Int, Value As Object)
Dim id As String = Value
Log(id)
End Sub
... ovvero come memorizzerei il record (player). Oh, è venuto decente ma... maremma hane, una label mi viene più "corta" di quanto dovrebbe.ma visto che sto provando una cosa..
Innanzi tutto grazie a tutti delle risposte! Siete stati molto gentili!
Stavo provando questa soluzione:
ma se metto il codice così nel log non succede niente...
se invece metto senza EventName nel log mi da 0 qualsiasi oggetto della lista tocchi...B4X:Private Sub EventNamexclv_ItemClick (Index As Int, Value As Object) Dim id As String = Value Log(id) End Sub
B4X:Private Sub xclv_ItemClick (Index As Int, Value As Object) Dim id As String = Value Log(id) End Sub
Scusate, ma non ho mai usato EventName, va inizializzato da qualche parte o in qualche modo?
Grazie di nuovo a tutti!
Esattamente. Quando nel Designer aggiungi la xCLV puoi vedere tra le Properties sia Name che EventName.Scusate, ma non ho mai usato EventName, va inizializzato da qualche parte o in qualche modo?
Ottieni sempre 0 perché hai usatose invece metto senza EventName nel log mi da 0 qualsiasi oggetto della lista tocchi...
xclv.Add(p,"")
xclv.Add(p,rs)
Private Sub xclv_ItemClick (Index As Int, Value As Object)
Dim id As ResultSet = Value
Log(id)
End Sub
No, questo lo avevo inizialmente, adesso hoOttieni sempre 0 perché hai usato
B4X:xclv.Add(p,"")
xclv.Add(p, rs.GetInt("ID") ) 'Id del Database
Ok, ho capito dov'era l'errore e adesso funziona, prende l'ID che è perfetto per quello che devo fare.Non capisco dove sbaglio...
wow! Grazie mille @LucaMs! Mi hai fatto addirittura il file d'esempio... c'è solo un problema: per me è arabo quello che hai fatto!Io farei come allegato.
Non credo che il rallentamento sia dato dai
Panel Size Unknown
Posta il codice di come leggi i dati dal DB per inserirli nella CLV.
'Scelgo quali dati voglio prendere dal Player DB
rs = Starter.sqlPlayers.ExecQuery("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS ORDER BY GEN DESC")
fill_clv (rs)
rs.Close
Private Sub edtSearchName_TextChanged (Old As String, New As String)
Dim rs As ResultSet
rs = Starter.sqlPlayers.ExecQuery2("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS where PlayerName like ? ORDER BY GEN DESC", Array As String($"%${ New }%"$))
fill_clv (rs)
rs.Close
End Sub
Private Sub edtSearchGen_TextChanged (Old As String, New As String)
Dim rs As ResultSet
rs = Starter.sqlPlayers.ExecQuery2("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE GEN like ? ", Array As String($"${ New }"$))
fill_clv (rs)
rs.Close
If New = "" Then
rs = Starter.sqlPlayers.ExecQuery("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS ORDER BY GEN DESC")
fill_clv (rs)
rs.Close
End If
End Sub
Private Sub spnTeam_ItemClick (Position As Int, Value As Object)
Dim rs As ResultSet
rs = Starter.sqlPlayers.ExecQuery2("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Team like ? ORDER BY GEN DESC", Array As String($"${ Value }"$))
If Position = 0 Then
rs = Starter.sqlPlayers.ExecQuery("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS ORDER BY GEN DESC")
End If
fill_clv (rs)
rs.Close
End Sub
Private Sub cbxG_CheckedChange(Checked As Boolean)
Dim rs As ResultSet
If cbxG.Checked=True And cbxF.Checked=True And cbxC.Checked=True Then
rs = Starter.sqlPlayers.ExecQuery("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS ORDER BY GEN DESC")
Else If cbxG.Checked=True And cbxF.Checked=True And cbxC.Checked=False Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='G' OR Pos2='G' Or Pos1='F' OR Pos2='F' ORDER BY GEN DESC")
Else If cbxG.Checked=True And cbxF.Checked=False And cbxC.Checked=True Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='G' OR Pos2='G' Or Pos1='C' OR Pos2='C' ORDER BY GEN DESC")
Else If cbxG.Checked=False And cbxF.Checked=True And cbxC.Checked=True Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='F' OR Pos2='F' Or Pos1='C' OR Pos2='C' ORDER BY GEN DESC")
Else If cbxG.Checked=True And cbxF.Checked=False And cbxC.Checked=False Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='G' OR Pos2='G' ORDER BY GEN DESC")
Else If cbxG.Checked=False And cbxF.Checked=True And cbxC.Checked=False Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='F' OR Pos2='F' ORDER BY GEN DESC")
Else If cbxG.Checked=False And cbxF.Checked=False And cbxC.Checked=True Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='C' OR Pos2='C' ORDER BY GEN DESC")
Else
rs = Starter.sqlPlayers.ExecQuery("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS ORDER BY GEN DESC")
End If
fill_clv (rs)
rs.Close
End Sub
Private Sub cbxF_CheckedChange(Checked As Boolean)
Dim rs As ResultSet
If cbxG.Checked=True And cbxF.Checked=True And cbxC.Checked=True Then
rs = Starter.sqlPlayers.ExecQuery("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS ORDER BY GEN DESC")
Else If cbxG.Checked=True And cbxF.Checked=True And cbxC.Checked=False Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='G' OR Pos2='G' Or Pos1='F' OR Pos2='F' ORDER BY GEN DESC")
Else If cbxG.Checked=True And cbxF.Checked=False And cbxC.Checked=True Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='G' OR Pos2='G' Or Pos1='C' OR Pos2='C' ORDER BY GEN DESC")
Else If cbxG.Checked=False And cbxF.Checked=True And cbxC.Checked=True Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='F' OR Pos2='F' Or Pos1='C' OR Pos2='C' ORDER BY GEN DESC")
Else If cbxG.Checked=True And cbxF.Checked=False And cbxC.Checked=False Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='G' OR Pos2='G' ORDER BY GEN DESC")
Else If cbxG.Checked=False And cbxF.Checked=True And cbxC.Checked=False Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='F' OR Pos2='F' ORDER BY GEN DESC")
Else If cbxG.Checked=False And cbxF.Checked=False And cbxC.Checked=True Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='C' OR Pos2='C' ORDER BY GEN DESC")
Else
rs = Starter.sqlPlayers.ExecQuery("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS ORDER BY GEN DESC")
End If
fill_clv (rs)
rs.Close
End Sub
Private Sub cbxC_CheckedChange(Checked As Boolean)
Dim rs As ResultSet
If cbxG.Checked=True And cbxF.Checked=True And cbxC.Checked=True Then
rs = Starter.sqlPlayers.ExecQuery("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS ORDER BY GEN DESC")
Else If cbxG.Checked=True And cbxF.Checked=True And cbxC.Checked=False Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='G' OR Pos2='G' Or Pos1='F' OR Pos2='F' ORDER BY GEN DESC")
Else If cbxG.Checked=True And cbxF.Checked=False And cbxC.Checked=True Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='G' OR Pos2='G' Or Pos1='C' OR Pos2='C' ORDER BY GEN DESC")
Else If cbxG.Checked=False And cbxF.Checked=True And cbxC.Checked=True Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='F' OR Pos2='F' Or Pos1='C' OR Pos2='C' ORDER BY GEN DESC")
Else If cbxG.Checked=True And cbxF.Checked=False And cbxC.Checked=False Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='G' OR Pos2='G' ORDER BY GEN DESC")
Else If cbxG.Checked=False And cbxF.Checked=True And cbxC.Checked=False Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='F' OR Pos2='F' ORDER BY GEN DESC")
Else If cbxG.Checked=False And cbxF.Checked=False And cbxC.Checked=True Then
rs = Starter.sqlPlayers.ExecQuery("Select ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE Pos1='C' OR Pos2='C' ORDER BY GEN DESC")
Else
rs = Starter.sqlPlayers.ExecQuery("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS ORDER BY GEN DESC")
End If
fill_clv (rs)
rs.Close
End Sub
Private Sub edtSearchGen_TextChanged (Old As String, New As String)
Dim rs As ResultSet
rs = Starter.sqlPlayers.ExecQuery2("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS WHERE GEN like ? ", Array As String($"${ New }"$))
fill_clv (rs)
rs.Close
If New = "" Then
rs = Starter.sqlPlayers.ExecQuery("SELECT ID, PlayerName, Pos1, Pos2, Team, GEN from PLAYERS ORDER BY GEN DESC")
fill_clv (rs)
rs.Close
End If
End Sub
Dovrai usare l'EventName della tua CustomListView per ItemClick.B4X:Sub EventNamexclv_ItemClick (Index As Int, Value As Object) Dim PlayerName As String = xclv.GetPanel(Index).GetView(0).Text Dim Pos1 As String = xclv.GetPanel(Index).GetView(1).Text Dim Pos2 As String = xclv.GetPanel(Index).GetView(2).Text Dim Team As String = xclv.GetPanel(Index).GetView(3).Text Dim GEN As String = xclv.GetPanel(Index).GetView(4).Text End Sub
Nell'esempio i GetView, da 0 a 4, potrebbero essere differenti dal tuo Layout.
Puoi sapere il numero da usare guardando il TreeView nel tuo Layout:
la View più in alto è la 0 e poi via a scendere.
Ho ipotizzato che nel Layout ci siano solo quelle 5 Labels.
E l'assegnazione a delle stringhe è puramente per esempio.
Private Sub xclv_ItemLongClick (Index As Int, Value As Object)
id = Value
Log(id)
Roster_Register 'salvo l'ID su un file txt
ToastMessageShow("Aggiunto al roster", True)
End Sub
xclv.Add(p, rs.GetString("ID"))
Cioè? Scusa l'ignoranza ma non so cosa sia il parsing del RS...In alternativa potresti rifare il parsing del RS nello stesso modo di quando popoli la CLV.
xclv.Add(p, rs)
Private Sub xclv_ItemLongClick (Index As Int, Value As Object)
Dim rs as ResultSet = value
id = rs.getstring("ID")
Log(id)
Roster_Register 'salvo l'ID su un file txt
ToastMessageShow("Aggiunto al roster", True)
End Sub
Non so se è possibile farlo, però proverei modificando quando popoli la CLV con
La gestione del clickB4X:xclv.Add(p, rs)
Se funziona così poi puoi usare i vari Getstring per prendere tutti i tuoi valori.B4X:Private Sub xclv_ItemLongClick (Index As Int, Value As Object) Dim rs as ResultSet = value id = rs.getstring("ID") Log(id) Roster_Register 'salvo l'ID su un file txt ToastMessageShow("Aggiunto al roster", True) End Sub
Però non ho lavorato con i DB quindi quello che ti ho scritto potrebbe non funzionare.
Si, ma avevo solo inserito i codice che mi avevi datoLì però hai tolto le modifiche che ti davano l'errore di View non inizializzata?
Perché senza non possiamo sapere cosa hai provato.
Dim Pos1 As String = xclv.GetPanel(Index).GetView(3).Text
Dim Pos2 As String = xclv.GetPanel(Index).GetView(4).Text
Dim GEN As String = xclv.GetPanel(Index).GetView(5).Text
Si, "Dim id As String" l'ho messa in GlobalsLa variabile id alla quale cerchi di assegnare il valore è una variabile globale definita prima?
Altrimenti l'errore potrebbe essere quello.
cur = Starter.sqlPlayers.ExecQuery("Select Gen, Pos1, Pos2 from PLAYERS WHERE ID='"& id & "'")
Log(cur.GetString("Pos1"))
Gen = rs.GetInt("Gen")
Pos1 = cur.GetString("Pos1")
Pos2 = cur.GetString("Pos2")
Credo sia perché è stato chiamato RS.close prima e quindi non sono più accessibili.Attempting to access a closed CursorWindow.Most probable cause: cursor is deactivated prior to calling this method."
xclv.Add(p, rs.getstring("ID"))
Private Sub xclv_ItemLongClick (Index As Int, Value As Object)
cur = Starter.sqlPlayers.ExecQuery("Select Gen, Pos1, Pos2 from PLAYERS WHERE ID='"& Value & "'")
Log(cur.GetString("Pos1"))
Gen = rs.GetInt("Gen")
Pos1 = cur.GetString("Pos1")
Pos2 = cur.GetString("Pos2")
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?