MOBILE

Developing BlackBerry Tablet Applications : OS Interactions - Screen Options

12/27/2013 2:52:01 AM

There are several options available to programmatically control several areas of the screen layout. These options determine the layout of the application, whether to show the action bar in View-Based or Tabbed application, and whether to show the application in full-screen mode. This sample application is shown in Figure 1.

1. Layout

The options for your application layout are portrait, where the application shows vertically in the device; or landscape, where the application shows horizontally in the device. Setting the aspect ratio by calling the setAspectRatio method on the stage can change the application’s layout. The StageAspectRatio class contains two static values that should be used to set the aspect ratio.

The following code includes a RadioGroup with the ID of orientation. There are two RadioButton components in this group with values of portrait and landscape. When clicking on one of these radio buttons, the radiobutton1_clickHandler method is called. Within this method, the orientation.selectedValue is tested. If orientation.selectedValue is equal to portrait, the stage.setAspectRatio method is called and StageAspectRatio.PORTRAIT is passed in. If orientation.selectedValue is equal to landscape, the stage.setAspectRatio method is called and StageAspectRatio.LANDSCAPE is passed in. The results are pictured in Figure 2.

2. ActionBar

The ActionBar is the built-in navigation that comes along with the View-Based or Tabbed application layouts. This bar consumes significant screen real estate. Therefore, the option to hide and show it programmatically is available to you as the developer.

The following code includes a CheckBox with the label “Show ActionBar”. This CheckBox is set to “selected” by default, as that is the normal state of the ActionBar. When clicking on this CheckBox to check or uncheck the value, the checkbox2_clickHandler is called. The actionBarVisible property of this view is set to the value of the CheckBox. The results are pictured in Figure 3, which shows an application that is in full screen with the ActionBar hidden.

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">

<fx:Script>
<![CDATA[
protected function checkbox2_clickHandler(event:MouseEvent):void
{
this.actionBarVisible = event.target.selected;
}

protected function radiobutton1_clickHandler(event:MouseEvent):void
{
if(orientation.selectedValue == "portrait"){
stage.setAspectRatio(StageAspectRatio.PORTRAIT);
} else if(orientation.selectedValue == "landscape"){
stage.setAspectRatio(StageAspectRatio.LANDSCAPE);
}
}

]]>
</fx:Script>

<fx:Declarations>
<s:RadioButtonGroup id="orientation"/>
</fx:Declarations>

<s:VGroup top="20" left="10">
<s:CheckBox click="checkbox2_clickHandler(event)" label="Show ActionBar"
selected="true"/>
<s:RadioButton groupName="orientation" value="portrait" label="Portrait"
click="radiobutton1_clickHandler(event)" selected="true"/>
<s:RadioButton groupName="orientation" value="landscape" label="Landscape"
click="radiobutton1_clickHandler(event)"/>
</s:VGroup>


</s:View>


Figure 1. Screen Options Application


Figure 2. Landscape Mode


Figure 3. ActionBar Hidden

Other  
  •  Developing BlackBerry Tablet Applications : OS Interactions - StageWebView
  •  Developing BlackBerry Tablet Applications : OS Interactions - Splash Screen
  •  Developing BlackBerry Tablet Applications : OS Interactions - Open in Browser
  •  iPhone Developer : Assembling Views and Animations - Transforming Views
  •  iPhone Developer : Assembling Views and Animations - Randomly Moving a Bounded View
  •  iPhone Developer : Assembling Views and Animations - Working with View Frames (part 2) - Other Utility Methods
  •  iPhone Developer : Assembling Views and Animations - Working with View Frames (part 1) - Adjusting Sizes , CGRects and Centers
  •  iPhone Developer : Assembling Views and Animations - View Geometry
  •  Windows Phone 7 : Drawing with Vertices and Matrices - Drawing Primitives
  •  Windows Phone 7 : Understanding Matrix Transformations (part 3) - Drawing Multiple Objects at Different Positions
  •  
    Top 10
    Review : Sigma 24mm f/1.4 DG HSM Art
    Review : Canon EF11-24mm f/4L USM
    Review : Creative Sound Blaster Roar 2
    Review : Philips Fidelio M2L
    Review : Alienware 17 - Dell's Alienware laptops
    Review Smartwatch : Wellograph
    Review : Xiaomi Redmi 2
    Extending LINQ to Objects : Writing a Single Element Operator (part 2) - Building the RandomElement Operator
    Extending LINQ to Objects : Writing a Single Element Operator (part 1) - Building Our Own Last Operator
    3 Tips for Maintaining Your Cell Phone Battery (part 2) - Discharge Smart, Use Smart
    REVIEW
    - First look: Apple Watch

    - 3 Tips for Maintaining Your Cell Phone Battery (part 1)

    - 3 Tips for Maintaining Your Cell Phone Battery (part 2)
    VIDEO TUTORIAL
    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
    Popular Tags
    Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8