Android Question CustomListView - change text on panel gadget child

Discussion in 'Android Questions' started by Waldemar Lima, May 14, 2019.

  1. Waldemar Lima

    Waldemar Lima Active Member Licensed User

    hello everyone !

    someone know how do I change the text of a label in a panel created in CustomListView?

    this is the sub what create new customlistview item :

    Code:
    Private Sub CreateItemProfile(Width As Int, Title As String, Description As String, FeedID As String, Banner As StringAs Panel
        
    Dim p As B4XView = xui.CreatePanel("")
        
    Dim height As Int = 210dip
        
    If GetDeviceLayoutValues.ApproximateScreenSize < 4.5 Then height = 250dip
        p.SetLayoutAnimated(
    000, Width, height)
        
    'p.LoadLayout("Card3")
        p.LoadLayout("search_profile")
        
        Label_nome.Text = Title
        Label_status.Text = Description

        
    'ImageView1.SetBitmap(xui.LoadBitmapResize(File.DirAssets, Image, 50%x,50%y , True))

        
    If (ProfileImg.IsInitialized = TrueThen
            
    'CardsAmount = CardsAmount + 1
            'Feeds.Put(CardsAmount,ImageView1)
            'Log("ImageViewID = "&Feeds.Get(CardsAmount))
            ProfileImg.Put(ImageView1,"https://"&Banner)
        
    Else
            
            
    Msgbox("Erro de alocação de memória ! 0x0543f","Erro interno !")
            
    ExitApplication
            
        
    End If

        
    Return p
    End Sub
    this is the Design : http://prntscr.com/no74b6

    i would like to change the text of " Label_status " , when lblAction is clicked in specific customlistview item...
     
  2. mangojack

    mangojack Well-Known Member Licensed User

  3. Waldemar Lima

    Waldemar Lima Active Member Licensed User

    dont works :c

    this is the event sub

    Code:
    Sub lblAction_Click
        
    Dim index As Int = CustomListView1.GetItemFromView(Sender)
        
        
    Log("lblAction is initialized ? : "&lblAction.IsInitialized)
        
        
    Dim pnl As B4XView = CustomListView1.GetPanel(0)
        
    Log(pnl.GetView(1))
    End Sub
    this is log error :
    Code:
    Logger conectado a:  Xiaomi Redmi 6
    --------- beginning of system
    --------- beginning of main
    *** 
    Service (starter) Create ***
    ** 
    Service (starter) Start **
    lblAction 
    is initialized ? : true
    search_profile_lblaction_click (java line: 
    598)
    java.lang.RuntimeException: Object should first be initialized (
    View).
        at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:
    50)
        at anywheresoftware.b4a.objects.B4XViewWrapper.GetView(B4XViewWrapper.java:
    298)
        at com.partygo.coldbyte.search_profile._lblaction_click(search_profile.java:
    598)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    196)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    180)
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:
    176)
        at anywheresoftware.b4a.objects.ViewWrapper$
    1.onClick(ViewWrapper.java:80)
        at android.view.View.performClick(
    View.java:6310)
        at android.view.View$PerformClick.run(
    View.java:24970)
        at android.os.Handler.handleCallback(Handler.java:
    794)
        at android.os.Handler.dispatchMessage(Handler.java:
    99)
        at android.os.Looper.loop(Looper.java:
    176)
        at android.app.ActivityThread.main(ActivityThread.java:
    6662)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:
    547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    873)
    this is screenshot of gadget tree of designer editor :
    upload_2019-5-15_1-49-37.png
     
  4. DonManfred

    DonManfred Expert Licensed User

    why you are NOT using the code @mangojack linked?
    Your code
    The Code linked:

    In fact you are using the label click event, not the clv itemclick event.

    to get the label in the labelclick event you can use
    Code:
    Sub lblAction_Click
        
    dim lblAction as label = sender
        
    ' work with label
    end sub
     
    mangojack likes this.
  5. mangojack

    mangojack Well-Known Member Licensed User

    Your code should be ..

    Code:
    Sub lblAction_Click
        
    Dim index As Int = CustomListView1.GetItemFromView(Sender)
        
        
    Log("lblAction is initialized ? : "&lblAction.IsInitialized)
        
        
    Dim pnl As B4XView = CustomListView1.GetPanel(index)
        
    Log(pnl.GetView(1).Text    ' Label_status is second label / view on panel layout ??
     
    jimmyF likes this.
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