Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
gpatton
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
Accepted Solution

Label visibility not working with actionItem

Hi,

I have an action item on my page. I want it to toggle the visibility two labels on my page. So when I click the action Item the first time, I want its title to change, Label1's visibility to toggle off and Label2's visibility to toggle on. And vice versa, when I hit the actionitem the second time. 

 

When I click it the first time, the visiblity changes (i.e. label1 = not visible, label2 = visible and title has been changed for action item).  However, it won't work the second time I click the button - it just stays at label2=visible and the title for the action item remains the same.

 

Any ideas? Here is my code below: 

 

 

Page {
    id: pageID
    Container {
        id: rootContainer
        Label {
            visible: true
            id: label1
            text: "Label 1"
        }
        Label {
            visible: false
            id: label2
            text: "Label 2"
        }
    }

    actions: [
        ActionItem {
            id: actionitem
            title: "View Label 2"
            ActionBar.placement: ActionBarPlacement.OnBar
            onTriggered: {
                if (label1.visible = true) {
                    label1.visible = false
                    label2.visible = true
                    actionitem.title = "View Label 1"
                } else if (label2.visible = true) {
                    label2.visible = false;
                    label1.visible = true;
                    actionitem.title = "View Label 2"
                }
            }
        }
    ]
}

 

Please use plain text.
Developer
raj_jyani
Posts: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE

Re: Label visibility not working with actionItem

Hi,

 

My Friend ther are diffent between "=" and "==" .

You have to write "==" (label1.visible = true)   in your code for check condition .
.


User console.log("") statement for debug.

 

Please use plain text.
Developer
gpatton
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900

Re: Label visibility not working with actionItem

Haha! Wow! I feel like an **bleep** (after 4 years of computer science). Can't believe I missed that one. Thanks man!
Please use plain text.