Android Question Download multiple items at once using Custom List View. How do I stop someone from pressing the Stop button?

Solution
You can also store it as the CustomListView item's "value" or in the tag of one of the views.
Yes I understand now thank you

B4X:
    Dim tracker As RangeDownloadTracker = Downloader.CreateTracker
    CustomListView1.AddTextItem("Cancel the second download",tracker)

Private Sub CustomListView1_ItemClick (Index As Int, Value As Object)
    Dim tr As RangeDownloadTracker = Value

    ' ✅ إلغاء التحميل
    tr.Cancel = True

    Log("تم إلغاء التنزيل رقم: " & Index)
End Sub

AlfaizDev

Well-Known Member
Licensed User
Setting Tracker.Cancel = True will cancel the download.
The problem is that I have more than one tracker, and every time I click the download button on CustomListView, a new tracker is created.
Dim tracker As RangeDownloadTracker = Downloader.CreateTracker
There can be up to five at once.

I want to use the cancel event,

but the problem is how do I know which tracker button to cancel?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Just set Tracker.Cancel = True on all running trackers
If you have multiple running you need to remember them
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
This is a small example of what I mean.
1. Don´t expect me checking your app.
2. If you create a tracker. REMEBER IT in a Map or a List.
3. If you want to chancel downloads go over all of them and set Tracker.Cancel = True
4. Learn coding
 
Upvote 0

AlfaizDev

Well-Known Member
Licensed User
You can also store it as the CustomListView item's "value" or in the tag of one of the views.
Yes I understand now thank you

B4X:
    Dim tracker As RangeDownloadTracker = Downloader.CreateTracker
    CustomListView1.AddTextItem("Cancel the second download",tracker)

Private Sub CustomListView1_ItemClick (Index As Int, Value As Object)
    Dim tr As RangeDownloadTracker = Value

    ' ✅ إلغاء التحميل
    tr.Cancel = True

    Log("تم إلغاء التنزيل رقم: " & Index)
End Sub
 
Last edited:
Upvote 0
Solution
Top