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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
My Carrier: Rogers
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"
                }
            }
        }
    ]
}

 

Developer
Posts: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE
My Carrier: AirTel

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.

 

Developer
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
My Carrier: Rogers

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!