Android Question Get value from view in customlistview

RUNO

Active Member
Licensed User
Longtime User
I have customlistview with many columns containing from image and label containing panel.
How I get text from label if user clicked on image .

img11.jpg
 
Last edited:

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
the image you uploaded is too small for me to see clearly, however,

you can assign the label to the tag of the image on creation (after load layout)

B4X:
img.tag = lbl

then in the click event
B4X:
private img as b4xview = sender
if (img.tag is label) then
log("text of label is "&img.tag.as(label).text)
end if
 
Upvote 0

RUNO

Active Member
Licensed User
Longtime User
the image you uploaded is too small for me to see clearly, however,

you can assign the label to the tag of the image on creation (after load layout)

B4X:
img.tag = lbl

then in the click event
B4X:
private img as b4xview = sender
if (img.tag is label) then
log("text of label is "&img.tag.as(label).text)
end if

Thanks @Andrew (Digitwell)
I changed an image.
I used your code but not work.
In items layout 3 panel every panel image & label .
If user clicked on image i want read value from label in panel.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User

Your screenshot means absolutely nothing as it's way too small.

Look at the code in the link below...


Enjoy...
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I changed an image.
I used your code but not work.
In items layout 3 panel every panel image & label .
If user clicked on image i want read value from label in panel.
@Andrew (Digitwell) 's solution works well if applied correctly. But, your explanation of your problem is not good. If you cannot express it well in English, your best bet is to upload your project or at least a clear copy of you designer item layout tree and the items layout where you will not need binoculars to see it. With your cooperation, your issue can be solved.
Also, take a look at @Peter Simpson 's project. It helped me a lot, way back when I needed a push.
 
Upvote 0

RUNO

Active Member
Licensed User
Longtime User
@Andrew (Digitwell) 's solution works well if applied correctly. But, your explanation of your problem is not good. If you cannot express it well in English, your best bet is to upload your project or at least a clear copy of you designer item layout tree and the items layout where you will not need binoculars to see it. With your cooperation, your issue can be solved.
Also, take a look at @Peter Simpson 's project. It helped me a lot, way back when I needed a push.

Thank you all for your attention to my problem
Maybe I couldn't explain the problem, so I upload a piece of code for you, maybe one of you can help me and all of you are able to that.
my code too primitive.
 

Attachments

  • Test.zip
    10.4 KB · Views: 88
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Here is a working version.

The comments with DIG: show the changes I have made.

  • You should respond to the click on the Imageview not the clv.
  • You weren't taking the data from the CLV row in Visiblerangechanged, I'm not sure why this worked before.

I would most probably make more use of functions if I were to write this for example.


For example,

B4X:
            m = MyList.Get(i+2)
            Dim link1 As String=URL &"ad1/image/pic/"& m.Get("folder")&"/"&m.Get("image")
            Dim id As Int=m.Get("id")
            Dim j As HttpJob
            j.Initialize("", Me)
            j.Download(link1)
            Wait For (j) JobDone(j As HttpJob)
            If j.Success Then
                id3  = CreateItem(link1,id,j.GetBitmap)
            End If

could become a function which takes a parameter and returns an image data

B4X:
private sub getimageandcreateitem(idx as int) as resumeablesub
private m as map
m = MyList.Get(id)
            Dim link1 As String=URL &"ad1/image/pic/"& m.Get("folder")&"/"&m.Get("image")
            Dim id As Int=m.Get("id")
            Dim j As HttpJob
            j.Initialize("", Me)
            j.Download(link1)
            Wait For (j) JobDone(j As HttpJob)
            If j.Success Then
                return  CreateItem(link1,id,j.GetBitmap)
            else
                return null
            End If
end sub

then getDT can be

B4X:
    For i = 0 To MyList.Size-1  Step 3
        Log(i)

        wait for (getimageandcreateitem(i)) complete (r As ImageData)
        id1 = r
 
        If (i+1) <MyList.Size Then
            wait for (getimageandcreateitem(i+1)) complete (r As ImageData)
            id2 = r
         
        Else
            ' id2.title = DIG: Bug here
            id2  = CreateItem("","",Null)
        End If
        If (i+2) <MyList.Size Then
            wait for (getimageandcreateitem(i+2)) complete (r As ImageData)
            id3 = r
        Else
            'id3.Title = DIG: Bug Here
            id3  = CreateItem("","",Null)

        End If

which is much easier to maintain

EDIT: Fixed bugs in example code above - copy/paste error (download file is correct)
 

Attachments

  • BasicxCLVLL.zip
    10.8 KB · Views: 87
Last edited:
Upvote 0
Top