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.
 

AnandGupta

Expert
Licensed User
Longtime User
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.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Another, simple, no-code solution: don't click twice :D

Sorry, I couldn't resist.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Another, simple, no-code solution: don't click twice :D

Sorry, I couldn't resist.
Actually the op will never click twice, but his users will. I have faced this in nearly all my released products.
It looks like the users are hell bent to find errors. GOD Bless them.
 
Upvote 0

pliroforikos

Active Member
Licensed User
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:
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

AnandGupta

Expert
Licensed User
Longtime User
Just add log and check,

B4X:
Private Sub clvStudents_ItemClick (Index As Int, Value As Object)

log("lockCLV " & lockCLV)

If lockCLV = True  Then
Return
End If
lockCLV = True
 
Upvote 0

pliroforikos

Active Member
Licensed User
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

AnandGupta

Expert
Licensed User
Longtime User
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?
Well posting your project (or sample one) may help experts here to solve it.
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
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:
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:
lockCLV = true
wait for (performResumeablesub) complete
lockclv = false

then lockCLV will not get reset until the resumeablesub is complete
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Everything is managed in the ItemClick event?
What about
B4X:
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

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
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

pliroforikos

Active Member
Licensed User
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
Top