Namespaces

Variants
Actions

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 over the next few weeks. Thanks for all your past and future contributions.

在程序的导航条中插入文本或图片

From Wiki
Jump to: navigation, search
Article Metadata

文章
huwell 在 18 Jan 2008 创建
最后由 hamishwillee 在 18 Oct 2011 编辑
* 开发伙伴平台:

S60 3rd Edition


  • 详细描述

S60应用程序在前台时,可以设置导航条显示自定义图标或文本。


首先,我们要获得一个状态栏的引用。然后可以从中获得导航栏的引用。应用程序可以使用CAknNavigationDecorator类生成一个基于文本的Navi decorator对象。最后这个对象需要添加到导航栏中以便开始显示:

//------------------------------------------------------------------------------
 
CAknNavigationControlContainer* iNaviPane = 0;
 
CAknNavigationDecorator* iNaviDecorator = 0;
 
//Get the reference of the status pane
 
CEikStatusPane *statusPane = iEikonEnv->AppUiFactory()->StatusPane();
 
if ( statusPane )
 
{
 
//Get the reference of the navi pane
 
iNaviPane=static_cast<CAknNavigationControlContainer*>(statusPane->ControlL(
 
TUid::Uid(EEikStatusPaneUidNavi)) );
 
//Create a Navi decorator object
 
iNaviDecorator= iNaviPane->CreateEditorIndicatorContainerL();
 
//Get the reference of the indicator container inside the NaviDecorator
 
CAknIndicatorContainer* indiContainer =
 
static_cast<CAknIndicatorContainer*>(iNaviDecorator->DecoratedControl());
 
if ( indiContainer && CEikStatusPaneBase::Current() )
 
{
 
TBuf<32> msgSize;
 
msgSize.Append(_L("Test")); // Text to be displayed
 
 
 
indiContainer->SetIndicatorValueL(
 
TUid::Uid( EAknNaviPaneEditorIndicatorMessageLength ), msgSize );
 
 
 
indiContainer->SetIndicatorState(
 
TUid::Uid( EAknNaviPaneEditorIndicatorMessageLength ),
 
EAknIndicatorStateOn);
 
}
 
 
 
//Push the object onto the navi pane.
 
iNaviPane->PushL( *iNaviDecorator );
 
}
 
//------------------------------------------------------------------------------


下面的这个示例代码,演示了如何在导航栏中显示一个图标:

//------------------------------------------------------------------------------
 
CFbsBitmap* bitmap = NULL;
 
CFbsBitmap* mask = NULL;
 
CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
 
CAknNavigationControlContainer* naviPane =
 
(CAknNavigationControlContainer*)statusPane->ControlL(
 
TUid::Uid(EEikStatusPaneUidNavi));
 
// Create an icon
 
AknIconUtils::CreateIconLC (bitmap, mask, KIconFile,
 
EMbmCarsvgCircle, EMbmCarsvgCircle_mask); //KIconFile is the .mif file
 
 
 
TSize size(30,30);
 
AknIconUtils::SetSize(bitmap, size); // Sets the size of the extracted image
 
//Create a Navi Decorator encapsulation for the image.
 
CAknNavigationDecorator* naviDecorator =
 
naviPane->CreateNavigationImageL(bitmap, mask);
 
//Push the image onto the navi pane.
 
naviPane->PushL(*naviDecorator);
 
//------------------------------------------------------------------------------


需要的头文件及库文件有:

#include <aknnavi.h>               // for CAknNavigationControlContainer
 
#include <eikspane.h> // for CEikStatusPane
 
#include <aknnavide.h> // for CAknNavigationDecorator
 
#include <akniconutils.h> // for AknIconUtils
 
#include <aknindicatorcontainer.h> // for CAknIndicatorContainer
 
LIBRARY aknicon.lib
 
LIBRARY fbscli.lib
 
LIBRARY avkon.lib


注意: 程序在前台时这些导航栏上的文字和图标才得以显现,但手机待机时却不会处理。

This page was last modified on 18 October 2011, at 05:45.
48 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×