Android Question custom view parent click

Status
Not open for further replies.

Kiran Raotole

Active Member
Licensed User
Hii experts,
My custom view Label class is working fine.
I add custom view label object in custom list view by add row function.
But customlistview_itemclick event is not running when I click on custom view.

Here is my code of custom cllick event
B4X:
Private Sub mBase_Click
    Log(mCallBack)
    Log(mEventName)
    If SubExists(mCallBack,mEventName &  "_Click") Then
        CallSub(mCallBack,mEventName & "_Click")
    End If
End Sub
How to do this?
 

Kiran Raotole

Active Member
Licensed User
no this is my custom view object
Code:
Private Sub mBase_Click
Log(mCallBack)
Log(mEventName)
If SubExists(mCallBack,mEventName & "_Click") Then
CallSub(mCallBack,mEventName & "_Click")
End If
End Sub
item click event is here
B4X:
Sub CustomListView1_ItemClick (Index As Int, Value As Object)
    Msgbox(Value,"")
End Sub
 

klaus

Expert
Licensed User
It would be much easier to help you if you posted your test project or a small project showing the problem.
 

Kiran Raotole

Active Member
Licensed User
uploaded my code here. In this I added two object one is my custom object and other default b4a object.
in customlistview.

Problem : when I click on b4a default object it run event customlistview_click,
but when I click on my custom object customlistview_click is not running.
 

Attachments

LucaMs

Expert
Licensed User
In your blabel (custom view) you have


Private Sub mBase_Click

but mBase is covered by Lbl:

Lbl.Initialize("Label1")
mBase.AddView(Lbl,0,0,Base.Width,mHeight)

So you have to handle its click event, not the mBase click event

Private Sub mBase_Click

Private Sub Label1_Click
 

LucaMs

Expert
Licensed User
The event name, the initial part of the event name, must be the name you used to initialize the view.

If I create a button this way:

Dim bntDoIt As Button
btnDoIt.Initialize("LucaMs")

then the Click routine must be:

Sub LucaMs_Click
 

LucaMs

Expert
Licensed User
Add this routine to the Main (in your project you attached in #9):
B4X:
Sub blabel1_Click
   Dim lb As blabel = Sender
   Dim index As Int = CustomListView1.GetItemFromView(lb.GetBase)
   Dim Value As Object = CustomListView1.GetValue(index)
   LogColor("bLabel1_Click", Colors.Blue)
   LogColor("Index: " & index, Colors.Blue)
   LogColor("Value " & Value, Colors.Blue)
   Msgbox(Value,"")
End Sub
(to better test the project you could change also:
CustomListView1.Add(add_row("custom view","default view"),a)
to
CustomListView1.Add(add_row("custom view","default view"), i)
)
 
Status
Not open for further replies.
Top