Android Question ScrollView and Timer

Shay

Well-Known Member
Licensed User
Longtime User
Hi

I have ScrollView in which each "line" has some picture
I wish to do the following:
each picture (line) will have it's own timer
so once you press picture X, timer will start
but you can press many pictures, in different time

I don't know how many pictures / timers I will have
(and timers are not sync between them)

How can I do it?
 

DonManfred

Expert
Licensed User
Longtime User
And then? What will you do when one of the running timer ticks?

I would suggest using a "List of Timers". You must find a way to pair a timer to an image. Maybe with the Tag-property

Or you can put a timer reference to the tag:

When creating a Listviewitem with an image you setup a new timer

B4X:
Dim t as Timer
t.Initialize("Timer")
and put it´s reference into the Images Tag
B4X:
img.Tag = t
and then, in the image click sub
B4X:
Sub image_Click
    Dim img As ImageView = Sender
    Dim t As Timer = img.Tag
    t.Enabled = True
End Sub

UNTESTED... Quick typed here in forum

If you need the Tag for some other information then you can use a map and put your other info AND a tier reference into this map and the map into the Tag property...

It depends on your needs
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
What do you want to do with the picture in the time tick event?

You could possibly have one timer and record the time the picture was clicked in a list or Map, then test for it in the timer event. It depends on what you want the timer to actually do.
 
Upvote 0
Top