在网格控件中动态显示图片和文字

 

void  CSimpleGridGamesGridPreview::SetupUseNewIconArray(CArrayPtr < CGulIcon >*  icons,CDesCArray  *  test)
    
{
        _LIT(KIS,
"0\t  ");
        TBuf
<256> convertBuf;
        CTextListBoxModel
* model = this->Model();  
        model
->SetOwnershipType (ELbmOwnsItemArray);
        CDesCArray 
* filenamearray = STATIC_CAST(CDesCArray*, model->ItemTextArray());
        filenamearray
->Reset();
        
//*(test[0]).Append(KIS);
        for(TInt i=0;i<test->Count();i++)
        
{
            
switch (i)
            
{
                
case 0:
                    convertBuf.Format(_L(
"0\t%S"),&(*test)[i]);
                    
break;
                
case 1:
                    convertBuf.Format(_L(
"1\t%S"),&(*test)[i]);
                    
break;
                
case 2:
                    convertBuf.Format(_L(
"2\t%S"),&(*test)[i]);
                    
break;
                
case 3:
                    convertBuf.Format(_L(
"3\t%S"),&(*test)[i]);
                    
break;
                
case 4:
                    convertBuf.Format(_L(
"4\t%S"),&(*test)[i]);
                    
break;
                
case 5:
                    convertBuf.Format(_L(
"5\t%S"),&(*test)[i]);
                    
break;
                
default:
                    
break;

            
            }

                        filenamearray
->AppendL(convertBuf);    
        }

        ItemDrawer()
->FormattedCellData()->SetIconArray(icons);
        SizeChanged();
    
    }

当然之前必须先通过RSS资源构建一个grid我们后来所做的只是改变图标的数组和text的数组而已

你可能感兴趣的:(图片)