The use of tags in cakncolumnlistbox is quite common. It is mainly used when multiple items are selected at the same time. Its main implementation steps are as follows:
1. Construction
Isavedgameslistbox-> constructl (this, eaknlistboxmarkablelist );
Use the eaknlistboxmarkablelist flag
2. Mark, unmark, mark all, and cancel all functions
case EAknCmdMark:case EAknCmdUnmark:case EAknMarkAll:case EAknUnmarkAll:{iAppContainer->HandleMarkCommandL (aCommand);break;}void CMarkableListContainer::HandleMarkCommandL(TInt aCommand){if (iSavedGamesListBox){AknSelectionService::HandleMarkableListProcessCommandL (aCommand, iSavedGamesListBox);}}
It can also be implemented using another method:
void CMarkableListContainer::HandleMarkL(){TInt index=iSavedGamesListBox->CurrentItemIndex();if(index<0)return;iSavedGamesListBox->View()->SelectItemL(index);}void CMarkableListContainer::HandleUnMarkL(){TInt index=iSavedGamesListBox->CurrentItemIndex();if(index<0)return;iSavedGamesListBox->View()->DeselectItem(index);}void CMarkableListContainer::HandleMarkAllL(){CTextListBoxModel* model = iSavedGamesListBox->Model();TInt itemCount = model->NumberOfItems();CListBoxView* listBoxView = iSavedGamesListBox->View();for (TUint i = 0; i < itemCount; i++){listBoxView->SelectItemL(i);}}void CMarkableListContainer::HandleUnMarkAllL(){CTextListBoxModel* model = iSavedGamesListBox->Model();TInt itemCount = model->NumberOfItems();CListBoxView* listBoxView = iSavedGamesListBox->View();for (TUint i = 0; i < itemCount; i++){listBoxView->DeselectItem(i);}}
Implementation of the reverse mark function:
void CMarkableListContainer::HandleMarkCommandOthersL(){CTextListBoxModel* model = iSavedGamesListBox->Model();TInt itemCount = model->NumberOfItems();CListBoxView* listBoxView = iSavedGamesListBox->View();for (TUint i = 0; i < itemCount; i++){if(listBoxView->ItemIsSelected(i)){listBoxView->DeselectItem(i);}else{listBoxView->SelectItemL(i);}}}