Android Question Multiple click on Item in CLV

pliroforikos

Active Member
Licensed User
Hello world.

I have some clvs with names of my students. When i click on a student then a new clv shows more details about him/her. For example the firstname, surname, tests points etc.
The data taken from a database in web.

The problem is when i double click the list item it fetches student information 2 times or more if i clicked fast enough.

The question is how i can prevent double or triple clicking on a list item before first click event run.
 
Another, simple, no-code solution: don't click twice :D

Sorry, I couldn't resist.
 
Upvote 0
There are multiple solution.
You can use public variable and set it true in called sub, return from sub if found true (second click) , set it false after done.
Or disable the clv on click,
etc.

I have already used first proposal like this

B4X: Copy
Private Sub clvStudents_ItemClick (Index As Int, Value As Object)
 If lockCLV = True  Then
        Return
    End If
    lockCLV = True

without succes, and at the end of clvStudents_ItemClick i turn flag to False
Are u using other place to check flag?
 
Upvote 0
In both clicks flag is false.

Maybe because i am using resumable function to get my data the program continues and flag goes back to true at then end?
 
Upvote 0
Here is a suggestion, without seeing some code, I can't be sure...

The problem is likely to be that you are resetting the lockClv to false without waiting for the resumable sub to complete

for example:
B4X: Copy
lockClV = true
PerformResumeableSub
LockCLV = false

in the example, lockCLV will only be true for a *VERY* short space of time

if you write the code like this:

B4X: Copy
lockCLV = true
wait for (performResumeablesub) complete
lockclv = false

then lockCLV will not get reset until the resumeablesub is complete
 
Upvote 0
Everything is managed in the ItemClick event?
What about
B4X: Copy
Private Sub clvStudents_ItemClick (Index As Int, Value As Object)
 clvStudents.AsView.Enabled = False
 
 ' Here do the Database read and other CLV compilation
 
 clvStudents.AsView.Enabled = True
 
Upvote 0
Ok,
if the database read or other operations use resumeable subs you need to use wait for or the processing will continue at this level.

see this thread which may help explain:
and

I would move the work out to a sub so that you can wrap the whole lot in one wait for at the itemclick level.
 
Upvote 0
Thank you all i will check asap your suggestions and i'll tell you about.

Now i am using this method as described above with a small improve.
lockCLV = true
wait for (performResumeablesub) complete
lockclv = false
 
Upvote 0
Back
Top