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
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Upvote 0

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

  • temp1.zip
    16.6 KB · Views: 369
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Temp1.zip is not a valid zip file.

Export your project using:

upload_2018-9-4_9-20-47.png
 
Upvote 0

LucaMs

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

LucaMs

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

npsonic

Active Member
Licensed User
yeah I got it, but if you add it in listview, listview.itemclick event while not work.
You can only get "Click" event from listview or from panel. Not both of them.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime 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)
)
 
Upvote 0
Status
Not open for further replies.
Top