## Enabling Avkon View Switching

The New Project wizard allows you to specify that you want automated support for Avkon View Switching in your project. This option must be set when the project is first created or the UI Designer will not generate the AppUi level code necessary to support view switching. Checking this option is sufficient to implement view switching automatically within projects that you have created with the wizard.

Legacy applications may already be configured to support view switching. If your legacy application is so configured, a few relatively simple manual edits to UI designs created with the S60 UI design wizard will add them to the switching group.

#### Implementing Avkon View Switching in a Project

1. Add Avkon View initialization code to <ProjectName>AppUi::ConstructL().

You must manually instantiate your view, and register it with the View Server.

Adopt the following code for your view's name, and add it to the ConstructL() method of your <ProjectName>AppUi class.

iMyView = CMyView::NewL();
AddViewL( iMyView );
SetDefaultViewL( *iMyView ); // if this view is the default

2. Add an enumerator for your view to the view id enumeration.

Open the <ProjectName>.hrh file. It will look something like this:

/*
============================================================================
Descriptive Information
============================================================================
*/
#ifndef __LEGACYPROJ_HRH__
#define __LEGACYPROJ_HRH__
// LegacyProj enumerate command codes
enum TLegacyProjIds
{
ECommand1 = 0x6001, // start value must not be 0
ECommand2
}
// LegacyProj view identifiers
enum TLegacyProjViewUids
{
ELegacyViewUid = 1
};
#endif // __LEGACYPROJ_HRH__

You must manually edit this file to add a Uid for your view to the enumeration. Add your new identifier to the end of the list. After editing the file, it could look like this:

/*
============================================================================
Descriptive Information
============================================================================
*/
#ifndef __LEGACYPROJ_HRH__
#define __LEGACYPROJ_HRH__
// LegacyProj enumerate command codes
enum TLegacyProjIds
{
ECommand1 = 0x6001, // start value must not be 0
ECommand2
}
// LegacyProj view identifiers
enum TLegacyProjViewUids
{
ELegacyViewUid = 1,
EMyDesignViewUid // UID for new view, named E ViewUid
};
#endif // __LEGACYPROJ_HRH__

When you have completed these steps, the view-switching aspects of this design should build and operate successfully.

##### Related tasks

- Creating New GUI Projects for the UI Designer

##### Related references

- New Project Wizard