Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Switching views on Symbian

From 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
Keywords: CAknView,CAknViewAppUi
Created: tepaa (09 Jun 2009)
Last edited: lpvalente (18 May 2014)



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:

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()
// Create your view derived from CAknView
iMyView = CMyView::NewL();
// Add view into control stack
// Use this as a default view

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


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 19:11.
89 page views in the last 30 days.