Android Question How to disable ItemClick event in CustomListView ?

sseaand

Member
Licensed User
Longtime User
How to disable ItemClick event from this panel in CustomListView ?
 

Attachments

  • 2017-10-19_091522.png
    2017-10-19_091522.png
    5 KB · Views: 293
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
If you do not write any sub automatically the touch is perceived by the underlying panel or the Activity to which it is attached, if you want it to click and nothing happens, this is the code you need

B4X:
Sub pnlExpanded_ItemClick
End Sub
 
Upvote 0

sseaand

Member
Licensed User
Longtime User
If you do not write any sub automatically the touch is perceived by the underlying panel or the Activity to which it is attached, if you want it to click and nothing happens, this is the code you need

B4X:
Sub pnlExpanded_ItemClick
End Sub
I did not write so, the question on CustomListView
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Sorry :(
Before you wrote about wanting to disable the event ItemClick. I answered this
 
Upvote 0

Misterbates

Active Member
Licensed User
So you have a layout that has two panels that you're using with CLV? If so, then you are in control of the click events through the designer (couple lines below the panel name is the event name) or through programmatic initialization (if not using a layout, .initialize(object, "event") and in your code you add the pnlExpanded routine that @Star-Dust posted - it'll make the panel non-responsive as well as block the touch from being passed to views under the panel.

If these replies still aren't making sense or providing an answer, perhaps you could post a small project that we can play with/adjust and pass back to you? Use the File/Export option in the IDE.
 
Upvote 0

jnjft

Member
Licensed User
Longtime User
How to disable ItemClick event from this panel in CustomListView ?
This is probably not what you are looking for, but it matches your title...
I have to disable the click event in CustomListView when the user has chosen a list item and changes the relating data shown in several fields of the activity. When changing data related to the chosen entry I don't want the user to activate another list item, of course. I found no solution to this in the CustomListView module, so I changed it a bit:
First I added a private variable 'Enabled' as Boolean to 'Class_Globals'. In 'Sub Initialize' I set this variable to True.
Then I added a public sub 'Enable' to the CustomListView module:
B4X:
Public Sub Enable(statusTrue As Boolean)
   If statusTrue Then Enabled = True Else Enabled = False
End Sub
And in the routines 'Panel_Click' and 'Panel_LongClick' I'm checking for the status of 'Enabled' and let the click go or not.
B4X:
Private Sub Panel_Click
   If Enabled Then
     If SubExists(CallBack, EventName & "_ItemClick") Then
       Dim v As View
       v = Sender
       CallSub3(CallBack, EventName & "_ItemClick", v.Tag, items.Get(v.Tag))
     End If
   End If
End Sub

Private Sub Panel_LongClick
   If Enabled Then
     If SubExists(CallBack, EventName & "_ItemLongClick") Then
       Dim v As View
       v = Sender
       CallSub3(CallBack, EventName & "_ItemLongClick", v.Tag, items.Get(v.Tag))
     End If
   End If
End Sub
That's it. I can then dim a CustumListView somewhere and enable or disable it as needed.
B4X:
Dim myclv as CustomListView
...
myclv.Initialize
myclv.Enable(False)
myclv.Enable(True)

Regards
jnjft
 
Upvote 0
Top