Android Question Get X coordinate in a custom list view

06Pierrick06

Member
Licensed User
Hi Forum

I'm using a customlistview composed of 2 similar panels



How could I determine if user clicked on the first or second panel in CustomListview_ItemClick (which only receives Index and Value) ?

I tried "Activity_touch" or "Panel_touch" to get the X value but then Customlistview_Item_click no more triggers.

Thanks in advance
 

06Pierrick06

Member
Licensed User
I'm sorry my level is too weak and I don't understand the answer.

I have added an inner panel which contains panel_left and panel_right
panel_left.tag and panel_right.tag are filled with values

This Sub always returns Null :

B4X:
Sub inner_panel_Click
    Dim pnl As View=Sender   
    Log(pnl.Tag)
End Sub

as well as this one :

B4X:
Sub inner_panel_Click
    Dim pnl As View=Sender
    dim pln2 as panel=pnl.parent
    Log(pnl2.Tag)
End Sub

Would you mind giving an exemple ?
 
Upvote 0

06Pierrick06

Member
Licensed User
Hi

I found a solution using a reflector to get X coordinate combined with CustomListView_ItemClick.
If X > screen.width /2 then user clicked the second item.
I guess there was probably a cleaner method...

B4X:
Dim r As Reflector
r.Target = p
r.SetOnTouchListener("scvTest_Touch")
   
    (...)
   
       
Sub scvTest_Touch(viewtag As Object, action As Int, X As Float, Y As Float, motionevent As Object) As Boolean
    Log(x)  
End Sub
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…