×
Namespaces

Variants
Actions

How to hide/show a setting item depending upon other setting item

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Code ExampleArticle
Created: rathodavinash (28 Jun 2007)
Last edited: hamishwillee (18 Sep 2012)

Suppose we have several setting items. Either we need to show them all or we need to hide specific ones and show them only when some setting item is selected. This article shows how to achieve it.

Create your setting list box. While the setting list is created you can choose which item to hide with the following code

CAknTextSettingItem* item3 = new (ELeave) CAknTextSettingItem(4, iAccountTag);
CleanupStack::PushL(item3);
item3->SetEmptyItemTextL( KEmptyText );
// The same resource id can be used for multiple text setting pages.
item3->ConstructL(isNumberedStyle, 4, KName2, icons, R_NAME_SETTING_PAGE, -1);
iItemList->SettingItemArray()->AppendL(item3);
item3->SetHidden(ETrue); //// HIDDEN
CleanupStack::Pop(item3);

Now in the OfferKeyEventL check if the desired condition to show the hidden item is true or false

TKeyResponse CMySettingContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType )
{
if(aType != EEventKey)
{
return EKeyWasNotConsumed;
}
else if(iItemList)
{
TKeyResponse keyResp =
iItemList->OfferKeyEventL(aKeyEvent, aType);
 
if(keyResp == EKeyWasConsumed && aKeyEvent.iCode == EKeyOK)
{
iItemList->StoreSettingsL();//Get settings
 
if(iAccountEmail.Find(KFlickrEmail)!=KErrNotFound)
{
((*iItemList->SettingItemArray())[2])->SetHidden(EFalse);
iItemList->HandleChangeInItemArrayOrVisibilityL();
iFlickrEnabled=ETrue;
}
else
{
((*iItemList->SettingItemArray())[2])->SetHidden(ETrue);
iItemList->HandleChangeInItemArrayOrVisibilityL();
iFlickrEnabled=EFalse;
}
}
 
return keyResp;
}
else
{
return EKeyWasNotConsumed;
}
}

Full example:

Ftsmwnjd(HideSettingItemDynamically).zip

Screenshots of the example applicatoin:

SettingsListOn.JPG SettingsListOff.JPG

This page was last modified on 18 September 2012, at 05:55.
41 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.

×