Anyway to stop an event such as an ItemClicked event?

jdiperla

Member
Licensed User
Longtime User
Just as the question says. Is there anyway to stop an event? For instance, I have a listview thats filling up. Once a user clicks an item I want the app to start the new activity but stop the event. It seems that no matter what I try, the app wont stop the event and keeps kicking me out of the new activity I started until the list is completely filled. Any command to stop events?
 

derez

Expert
Licensed User
Longtime User
If I understand correctly, it is not the click event that you want to stop but the listview filling.
You'll have to show us the code of this specific part, how the listview is made, and the click event sub.
Also, what should happen to the first activity.
 
Upvote 0

jdiperla

Member
Licensed User
Longtime User
Well, I have a sub, which is run at start up.

B4X:
dljpg(1).Initialize("2", Me)
dljpg(1).Download("http://www.xxxx.xxx2.jpg")

dljpg(1).Initialize("2", Me)
dljpg(1).Download("http://www.xxxx.xxx2.jpg")

dljpg(1).Initialize("2", Me)
dljpg(1).Download("http://www.xxxx.xxx2.jpg")

dljpg(1).Initialize("2", Me)
dljpg(1).Download("http://www.xxxx.xxx2.jpg")

on JobDone

B4X:
Select job.jobname
Case "2"
   Bitmap1.Initialize3(Job.GetBitmap)
    Listview1.AddTwoLinesandBitmap("2", "download", Bitmap1)   
   Job.release
   Return   
end select

etc... I am just using an example here as I do not want to put my apps code here as it is a paid app. However, this fills up the listview up to about 120 items, each item downloads an image to use on the list view.

On the Listview ItemClick:

B4X:
If Value = "2" Then
StartActivity(NEWACTIVITY)

What I am trying to do is once an item is clicked in the listview, it stops the sub thats loading the listview and just goes into that activity. What its doing now is simply when you click on the item, it starts the new activity, but exits out of the activity and goes to the listview screen everytime the next item is loaded and then returns to the new activity(Sometimes). It will do this until the whole list item is stored up. I just want to be able to stop the sub.

As for the first activity.. I want it to remain open in the background so if the user wants to back out, they can, but I want to end the sub.
 
Upvote 0

derez

Expert
Licensed User
Longtime User
You can control the sequence of events with a global flag:
Set it to false at the begining.
launch each dljpg only if the flag is still false
B4X:
if flag = false then
dljpg(1).Initialize("2", Me)
dljpg(1).Download("http://www.xxxx.xxx2.jpg")
End If

to make sure that those that managed to slip through before you changed the flag are not interfering, put a gate at on JobDone
B4X:
If flag then return

and of course, change the flag to True in the ItemClick event:
B4X:
If Value = "2" Then
flag = true
StartActivity(NEWACTIVITY)
 
Upvote 0
Top