Android Question custom view parent click

Discussion in 'Android Questions' started by Kiran Raotole, Sep 3, 2018.

Thread Status:
Not open for further replies.
  1. Kiran Raotole

    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
    Code:
    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?
     
  2. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    and
    change "_itemclick" to "_Click"
     
  3. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    no this is my custom view object
    item click event is here
    Code:
    Sub CustomListView1_ItemClick (Index As Int, Value As Object)
        
    Msgbox(Value,"")
    End Sub
     
  4. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    do you want to call this:
    with this?
     
  5. klaus

    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.
     
  6. LucaMs

    LucaMs Expert Licensed User

  7. Kiran Raotole

    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.
     

    Attached Files:

  8. LucaMs

    LucaMs Expert Licensed User

    Temp1.zip is not a valid zip file.

    Export your project using:

    upload_2018-9-4_9-20-47.png
     
  9. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    ok
     

    Attached Files:

  10. LucaMs

    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
     
  11. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    Private Sub Label1_Click is not working

    Private Sub Lbl_Click is work

    thanks
     
  12. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    after changing like this
    in activity blabel_click event not work
     
  13. LucaMs

    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
     
  14. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    yeah I got it, but if you add it in listview, listview.itemclick event while not work.
     
  15. npsonic

    npsonic Active Member Licensed User

    You can only get "Click" event from listview or from panel. Not both of them.
     
  16. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    for other object it works fine.
     
  17. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    I want to run both event.
     
  18. LucaMs

    LucaMs Expert Licensed User

    Add this routine to the Main (in your project you attached in #9):
    Code:
    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)
    )
     
  19. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    Is there is no solution in custom object? like using parent
     
  20. LucaMs

    LucaMs Expert Licensed User

    I don't know what you mean; have you tried adding that routine?

    upload_2018-9-5_14-42-41.png

    :)
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice