×
Namespaces

Variants
Actions
(Redirected from CS001413 - Switching views)

Switching views on Symbian

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
CompatibilityPlatform Security
Signing Required: Self-Signed
Capabilities: None
Article
Keywords: CAknView,CAknViewAppUi
Created: tepaa (09 Jun 2009)
Last edited: lpvalente (18 May 2014)

Contents

Overview

This snippet demonstrates how to switch views. The snippet uses the Avkon View-Switching Architecture class CAknView.

When and why do we need views?

  • When your application has multiple screens that form complex navigational paths.
  • When you want to save data on every view switching, to update the model with the newly entered or updated data.
  • When you want to send data from one screen to another or to external applications.
  • CAknView handles menu-commands, switching of views, sending keyboard/pointer events to the respective container class.
  • Simple applications don't need views that are derived from CAknView.

The S60 view architecture is used in application development in the S60 platform. Each view has its own control stack. The view architecture uses the base class CAknViewAppUi for the UI controller. The UI controller manages one or more CAknView derived views. The view class uses CCoeControl-derived container control.


MMP file

The following libraries and capabilities are required:

CAPABILITY None
 
LIBRARY avkon.lib
LIBRARY eikcore.lib
LIBTATY eiksrv.lib

Header file

#include <aknview.h>
#include <aknviewappui.h>


Source file

Application app UI class CAknViewAppUi creates the default view on its construction.

void CSomeAppUi::ContructL()
{
BaseConstructL(EAknEnableSkin);
// Create your view derived from CAknView
iMyView = CMyView::NewL();
// Add view into control stack
AddViewL(iMyView);
// Use this as a default view
SetDefaultViewL(*iMyView);
}

CAknView activates the control of the view. DoActivateL() is called by the View Server when a client requests that your view is activated.

void CSomeView::DoActivateL(const TVwsViewId& aPrevViewId,
TUid aCustomMessageId,
const TDesC8& aCustomMessage)
{
if (iSomeControl == NULL)
{
// Create control for the view
iSomeControl = CSomeContainer::NewL(ClientRect());
// Add it to control stack
AppUi()->AddToStackL(*this, iSomeControl);
}
}
 
void CSomeView::DoDeactivate()
{
if (iSomeControl != NULL)
{
// Remove view from the control stack
AppUi()->RemoveFromViewStack(*this, iSomeControl);
// Delete view
delete iSomeControl;
iSomeControl = NULL;
}
}

To switch to a view within your application, you can use the AppUi class method ActivateLocalViewL(). The new view is activated first, and the previous view is deactivated after that.

const TUid KSomeViewId = { 1 }; // UID of the some view
ActivateLocalViewL(KSomeViewId); // activate some view


Postconditions

Views can be activated and switched.


See also

Version Hint

Windows Phone: [[Category:Windows Phone]]
[[Category:Windows Phone 7.5]]
[[Category:Windows Phone 8]]

Nokia Asha: [[Category:Nokia Asha]]
[[Category:Nokia Asha Platform 1.0]]

Series 40: [[Category:Series 40]]
[[Category:Series 40 1st Edition]] [[Category:Series 40 2nd Edition]]
[[Category:Series 40 3rd Edition (initial release)]] [[Category:Series 40 3rd Edition FP1]] [[Category:Series 40 3rd Edition FP2]]
[[Category:Series 40 5th Edition (initial release)]] [[Category:Series 40 5th Edition FP1]]
[[Category:Series 40 6th Edition (initial release)]] [[Category:Series 40 6th Edition FP1]] [[Category:Series 40 Developer Platform 1.0]] [[Category:Series 40 Developer Platform 1.1]] [[Category:Series 40 Developer Platform 2.0]]

Symbian: [[Category:Symbian]]
[[Category:S60 1st Edition]] [[Category:S60 2nd Edition (initial release)]] [[Category:S60 2nd Edition FP1]] [[Category:S60 2nd Edition FP2]] [[Category:S60 2nd Edition FP3]]
[[Category:S60 3rd Edition (initial release)]] [[Category:S60 3rd Edition FP1]] [[Category:S60 3rd Edition FP2]]
[[Category:S60 5th Edition]]
[[Category:Symbian^3]] [[Category:Symbian Anna]] [[Category:Nokia Belle]]

This page was last modified on 18 May 2014, at 22:11.
115 page views in the last 30 days.
×