// Get the name of the file containing the icons
HBufC* iconFileName;
iconFileName = StringLoader::LoadLC(R_ICON_FILE_NAME); // Pushes iconFileName onto the Cleanup Stack.
// Create an array of icons, reading them from the file
CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(ArrayLength);
CleanupStack::PushL(icons);
//add icons
if (ArrayLength != 0)
{
for (TInt i=0; i<ArrayLength; i++ )
{
icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSmsorLog, EMbmSmsorLog_mask));
}
}
iLogListBox->ItemDrawer()->ColumnData()->SetIconArray(icons); // passing ownership of icons
}
void CListContainer::ReadDataFromFile()
{
RFs& fs = CCoeEnv::Static()->FsSession(); // 'global' file server session
CDesCArray* array = new(ELeave) CDesCArrayFlat(1); // use this array type rather
CleanupStack::PushL(array);
//check if we've reached end of file
if (buf8.Length() != 40)
break;
}
// get array length
ArrayLength = 0;
ArrayLength = array->Length();
//Add to list box
CTextListBoxModel* model = iLogListBox->Model();
MDesCArray* textArray = model->ItemTextArray();
CDesCArray* listBoxItems = static_cast<CDesCArray*>(textArray);
//insert items to listbox
if (ArrayLength != 0)
{
for (TInt i=0; i<ArrayLength; i++ )
{
//when i comment this line it dont get crash and loads 2 items
//which i've in .rss file
listBoxItems->AppendL(array->MdcaPoint(i));
}
}
/* //
iLogListBox->Model()->SetItemTextArray(array);
iLogListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
*/
iLogListBox->HandleItemAdditionL(); // This also redraws the list box.
iLogListBox->SetCurrentItemIndex(0);
iLogListBox->SetFocus(ETrue);
// close file and clean up
CleanupStack::PopAndDestroy(2,array); // array & file
}
Are you getting a panic code? Also are you working in the emulator on on the device?
Type of listbox is...
iLogListBox = new (ELeave) CAknSingleGraphicStyleListBox;
... so you have to include a graphic index for each line in your listbox.
eg
for (TInt i=0; i<array->Count(); i++)
{
TFileName listitem(_L("0\t")); // the 0 indicates the 1st graphic in your list as set up in SetupListIconsL()
listitem += (*array)[i]; // add the actual text you want to display
listBoxItems->AppendL(listitem);
}
iLogListBox->HandleItemAdditionL();