Android Question get itm idx from xCLV that has a panel with panel+xCLV, and has a items panels, crazy

chompina

Member
Licensed User
Longtime User
Hi, i can't get index from
Dim indx As Int=clvListaTareasCard.GetItemFromView(Sender)

i have a 2 layout
(a)-one with principal panel(pnlCard) that hold 1 child panel(datetime info) and 3 buttons outside child panel (Compartir, Completar, Eliminar)
(b)-another layout with principal panel(pnlCard) that hold 2 child panels
b.1-one child panel like point (a) (datetime info)
b.2-another child panel(pnlLista) that hold a xCLV1 with items panels (the list of items s,q,w,e).

with point (a) and point (b.1) i can determine index from 3 buttons (Compartir, Completar, Eliminar)

but with point (b.2) i can't get the index of this list (s,q,w,e) to interact with this 2 fontawesome labels colors when clic ,etc...


1690147640673.png


layout frmPrincipalHolder
1690148467130.png


2 different layout
1690148564548.png


another panel layout inside of clvListaTareasCard
1690148616867.png


when clic one of three button work great
1690148675640.png


when trying to use basic code,, and testing testing various spagetti code, trying to find solution
1690148751016.png




i want to determine de index of items inside of clvListaTareasCard to interact with description, labels colors, etc.
have a day (24 hour) testing testing, can't find solution or behavior.

1690149546348.png


please help! ... thank you
 
Solution
hi..
I found how to do it, I don't know if it's a best practice, but now it's working

having hours testing and testing..omg.

in the click events of two icons (X and check),, named lblcmdListaAprobar_Click and lblcmdListaNoAprobar_Click
i do this.

Aprobar:
Private Sub lblcmdListaAprobar_Click
    Dim cmdFont As B4XView=Sender
    cmdFont.Parent.GetView(1).TextColor=Colors.LightGray
    cmdFont.Parent.GetView(2).TextColor=Colors.RGB(0,200,0)
    Return
    'remover de aqui para abajo
Try
        Dim indx As Int=clvListaTareasCard.GetItemFromView(Sender)
        Dim panel As B4XView=clvListaTareasCard.GetPanel(indx)
        Msgbox(panel.GetView(0).GetView(0).Text ,"")
        panel.GetView(0).GetView(1).TextColor=Colors.LightGray...

Mahares

Expert
Licensed User
Longtime User
have a day (24 hour) testing testing, can't find solution or behavior.
I hope you can find someone that can understand all these complicated screenshots and therefore your thread, but if you can't, you need to reproduce your problem in a small or the original project and export to the forum. The time you spent creating these complicated screenshots with too many views would have been better spent putting together a project posted to the forum. You would stand a better chance of someone testing it and replying to your thread.,
 
Upvote 0

chompina

Member
Licensed User
Longtime User
creating a small proyect...

this code
Dim Index As B4XView=clvListaTareasCard.GetItemFromView(Sender)

a items panels in xclv upper container panel, and another principal container panel, is part of principal list of xclv
that i looking for,, it is working 😳

I am analyzing what is happening...

i will create another small proyect,, removing codes and libraries i will test to look what happening..
 
Upvote 0

chompina

Member
Licensed User
Longtime User
i got...
testing and testin... the last panel loaded in xclv its working,, only the last.. like this photo
1690213483787.png

i don't know what is.., previous loaded panel type "List" inside, i get error trying returnin index with xclv.GetItemFromView(Sender)
.. the last type "List" is working..

in the next post in a few minuts, i will uploaded test project, let me clean more codes.
 
Upvote 0

chompina

Member
Licensed User
Longtime User
test this please...
1-open app
2-go to the number 3, tap on check, or uncheck (not work)
3-go to the number 5, tap on check, or uncheck (work)
4-delete (elimina) number 5
5-go to the number 3, tap on check, or uncheck (not work)
6-tap reload and go to the number 3, test it (work)
7-go to the number 2, tap on check, or uncheck (not work) , if you delete number 3, reload, and test number 2, it work.

if you delete all, tap on Recreate to recreate the database, or go back twice to close, when open app, the database will create again.

any suggestion ? 😭
 

Attachments

  • TodoListTest.zip
    27.3 KB · Views: 62
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
You loaded the layout once, then added it to the CLV. So only the last panel in your list has the "sender".
The solution, for EACH item, make a new panel and load the layout.

B4X:
'If ..'
        pnl.LoadLayout("frmCardLista")
        
        For i = 0 To LaListaTareas.Size-1
        Next
        
'End If
    
    Lalista.Add(pnl,"")
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
The attachment is still quite complex, so haven't found the exact place where it went wrong.
Part of the problem for me is the use of a Code Module, which I never do.
Code modules don't do views. I don't know what happens if you use a B4XMainPage global holder of a view that gets loaded in
the code module.

But I can assure you that only the last card loaded has the appropriate arrangements of views.
The error that causes the exception is: the sender is not what you expect.

I will go at again tomorrow, unless it is solved.

Note: You have a scrollable view inside a CLV, how do you scroll it?
 
Upvote 0

chompina

Member
Licensed User
Longtime User
Note: You have a scrollable view inside a CLV, how do you scroll it?
I was asking myself the same question, and by mistake I was able to scroll🤣

with one finger touch and hold the main clv (to stop scroll), and with other finger (other hand of course), now you can scroll the inside view.
...
.. i create array of Panels

loaded work, but same problem..:
Dim pnfinal (LaListaTareas.Size) As B4XView
    For i = 0 To LaListaTareas.Size-1
        pnfinal(i)=xui.CreatePanel("")
        pnfinal(i).As(B4XView).SetLayoutAnimated(0,0,0,B4XPages.MainPage.clvListaTareascard.sv.width,30dip)
        pnfinal(i).As(B4XView).LoadLayout("frmCheckListaTareas")
        B4XPages.MainPage.clvListaTareascard.Add(pnfinal(i) ,i)
    Next

Lalista.Add(pnl,"")
 
Upvote 0

chompina

Member
Licensed User
Longtime User
hi..
I found how to do it, I don't know if it's a best practice, but now it's working

having hours testing and testing..omg.

in the click events of two icons (X and check),, named lblcmdListaAprobar_Click and lblcmdListaNoAprobar_Click
i do this.

Aprobar:
Private Sub lblcmdListaAprobar_Click
    Dim cmdFont As B4XView=Sender
    cmdFont.Parent.GetView(1).TextColor=Colors.LightGray
    cmdFont.Parent.GetView(2).TextColor=Colors.RGB(0,200,0)
    Return
    'remover de aqui para abajo
Try
        Dim indx As Int=clvListaTareasCard.GetItemFromView(Sender)
        Dim panel As B4XView=clvListaTareasCard.GetPanel(indx)
        Msgbox(panel.GetView(0).GetView(0).Text ,"")
        panel.GetView(0).GetView(1).TextColor=Colors.LightGray
        panel.GetView(0).GetView(2).TextColor=Colors.RGB(0,200,0)
    
    Catch
        Log(LastException)
    End Try
End Sub
NoAprobar:
Private Sub lblcmdListaNoAprobar_Click
    Dim cmdFont As B4XView=Sender
    cmdFont.Parent.GetView(1).TextColor=Colors.RGB(200,0,0)
    cmdFont.Parent.GetView(2).TextColor=Colors.LightGray
    Return
    'remover de aqui para abajo
Try
        Dim indx As Int=clvListaTareasCard.GetItemFromView(Sender)
        Dim panel As B4XView=clvListaTareasCard.GetPanel(indx)
        Msgbox(panel.GetView(0).GetView(0).Text ,"")
        panel.GetView(0).GetView(1).TextColor=Colors.RGB(200,0,0)
        panel.GetView(0).GetView(2).TextColor=Colors.LightGray
    
    Catch
        Log(LastException)
    End Try
End Sub
1690269596300.png

any other solution is welcome
 
Last edited:
Upvote 0
Solution

Mahares

Expert
Licensed User
Longtime User
any other solution is welcome
You can in the designer give the two labels lblcmdListaNoAprobar and lblcmdListaAprobar the same event name: lbl. Then assign a tag of 1 to the noaprobar label and 2 to the aprobar label. Then you can use this shortened code:
B4X:
private Sub lbl_Click
    Dim cmdFont As B4XView=Sender
    If 1 = cmdFont.Tag Then
        cmdFont.Parent.GetView(1).TextColor=Colors.RGB(200,0,0)
        cmdFont.Parent.GetView(2).TextColor=Colors.LightGray
        Log(cmdFont.Parent.GetView(0).Text  & " no aprobar")    'shows you the content of lblTitulo 
    Else
        cmdFont.Parent.GetView(1).TextColor=Colors.LightGray
        cmdFont.Parent.GetView(2).TextColor=Colors.RGB(0,200,0)
        Log(cmdFont.Parent.GetView(0).Text  & "  aprobar")    'shows you the content of lblTitulo
    End If
End Sub
 
Upvote 0
Top