Earlier this week I stumbled upon a request for someone wanting to create a feature that is present in the native Calendar app and I thought it would make for a great tutorial. What they wanted to mimic was to allow the user to set a default tab when opening the app. The use case in the Calendar app is you can choose between Day, Week, or Month for your default view. Not only do I think this is a neat ability, there’s probably a few more use cases.
I’ve created a sample app available on the Weekend Coder github site and I suggest pulling that open and following along while reading through the tutorial. Now let’s take a look at the pieces that make up this app.
First create a project with a TabbedPane view. This is easily done selecting the premade template while creating a new project or check out my earlier tutorial on tabbed panes.
Next, we need a place to house our page where the user will select their default tab. So much like the Calendar app, in my sample I’ve created a page accessible from the swipe from the top bezel . My settings page is very simple, just a dropdown of the three choices; Tab 1, Tab 2, and Tab 3. This is all we need for UI.
Now, it’s time to make some magic happen. In the DropDown we need it control the activeTab attribute of the TabbedPane. The method I used to do this is to have the DropDown control a int property I have named myDefaultTab, where 1 refers to Tab 1, 2 to Tab 2, and 3 to Tab 3. Now you should see that the activeTab property have corresponding logic.
Finally, we need to have a method to save what you choose in your DropDown after you close the app because, after all, that is exactly what we want to achieve. Without having a save/load method the activeTab would be whatever we defined myDefaultTab value as. So in the applicationui.cpp and .hpp files there are two functions setup to handle the saving/loading of this data. They are saveValueFor() and getValueFor() and I expose them to the QML by setting the context property as _app.
So take a look at the sample code and load it up [on a Z, Q or simulator] to see it in action. I purposely left it very plain looking to not clutter it with fluff/junk. Hope you enjoyed this sample and explanation. Sound off in the comments with any questions or remarks.
Read more
BlackBerry 10 device simulators updated to 10.3.1.2072
A little something for BlackBerry developers. If you head over to the BlackBerry developer site, you'll find a new batch of device simulators available for download. The last release shows them as running v10.3.1.2072 which should help with testing out any apps you're working on. As always, they're available for Window, Mac and Linux via VMWare images. There is no notable changes or...
BlackBerry OS 10.3.1.1949 device simulator now available
Just a little bit of a heads up for any developers (and those who just like to play around) who might not have spotted the update as of yet. You can now download the latest device simulator from the BlackBerry website, which sits at OS 10.3.1.1949. Keep in mind, if you plan on giving it a look you will need some VMWare tools in order to run it all but you can find the full details on...
Watch the application infrastructure for BES12 webcast
If you missed out on the application infrastructure for BES12 webcast on December 4th, you can now catch the replay of the event on your own time. We'll review the mobile app infrastructure built into BES 12 including how corporate systems can minimize risk when opening access to apps outside their firewall, and ensure data is secure through its journey from inside the corporate...
Application Infrastructure for BES 12 webcast
Creating apps for Enterprise customers can keep a developer busy but when doing so corporate data and systems need to be carefully managed. If you're building apps for BES12 customers, BlackBerry is hosting an application infrastructure for BES12 webcast on December 4, 2014, at 2 pm – 3 pm EST to help educate corporate app developers about best practices. We'll review the mobile...