ListBox的一點心得!

這兩天在看SDK EXAMPLE的LISTBOX例子,有一些心得與大家分享,有什麼錯誤請大家指出。

在例子中就用了2個LISTBOX的類,一個是CEikColumnListBox;另一個是CEikFormatte

dCellListBox。它們分別對應SINGLE和DOUBLE兩種表現形式。下面用代碼來說明一下



代碼:
CEikColumnListBox* iColListBox;
CEikFormattedCellListBox* iForListBox;

iColListBox = new (ELeave) CAknSingleStyleListBox();
iForListBox = new (ELeave) CAknDoubleGraphicStyleListBox();

iColListBox->SetContainerWindowL( *this );
iForListBox->SetContainerWindowL( *this );

//從資源文件中生成LISTBOX
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC( reader, R_TEST_SINGLE);
iColListBox->ConstructFromResourceL( reader );

CEikonEnv::Static()->CreateResourceReaderLC( reader, R_TEST_DOUBLE);
iForListBox->ConstructFromResourceL( reader );

//設置SCROLLBAR
iColListBox->CreateScrollBarFrameL( ETrue );
iColListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );

iForListBox->CreateScrollBarFrameL( ETrue );
iForListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );

//適合窗口大小
iColListBox->SetRect(Rect());
iForListBox->SetRect(Rect());

//激活
iColListBox->ActivateL();
iForListBox->ActivateL();


//資源.RSS

RESOURCE LISTBOX r_text_single
{
// 給定要生成LISTBOX的ITEMS
array_id = r_array_single;
// LISTBOX的標示
flags = EAknListBoxSelectionList;
}

RESOURCE LISTBOX r_text_double
{
array_id = r_array_double;
flags = EAknListBoxSelectionList;
}

//請注意r_array_single和r_array_double的不同。
// /t 就是分割符。
// "0/tAAAAAA/taaaaaa"最前的0表示在*.mbm中序號爲0的圖片加到LISTBOX的ITEM前
RESOURCE ARRAY r_array_single
{
items =
{
LBUF
{
txt = " /taaaaaa";
},
LBUF
{
txt = " /tbbbbbb";
}
};
}

RESOURCE ARRAY r_array_double
{
items =
{
LBUF
{
txt = "0/tAAAAAA/taaaaaa";
},
LBUF
{
txt = "0/tBBBBBB/tbbbbbb";
}
};
發佈了55 篇原創文章 · 獲贊 3 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章