CAknPopupFieldText在表单中动态创建及动态增加数组列表的操作
2008-05-29 09:18
525 查看
折腾了一天终于把CAknPopupFieldText在表单中动态创建及动态增加数组列表的操作搞定,主要分为以下几步:
1、定义资源文件
RESOURCE ARRAY r_settings_choice_std
{
items =
{
LBUF
{
txt = qtn_appl_test;
},
LBUF
{
txt=qtn_appl_help;
}
};
}
RESOURCE POPUP_FIELD_TEXT r_popup_dynamic_question {
popupfield = POPUP_FIELD {
width = 10;
};
textarray = r_settings_choice_std;
active = 0;
}
2、在CAknForm字类中增加变量
CDesCArray *iItemArray;
CAknQueryValueTextArray *iTextArray;
CAknQueryValueText *iQueryValText;
3、PreLayoutDynInitL()函数中增加以下代码
//增加一个CAknPopupFieldText控件
HBufC* buftemp=StringLoader::LoadLC(QTN_NAVI_LABEL_CONTACTGROUPVIEW);
CCoeControl* popupControl = CreateLineByTypeL(*buftemp, ActivePageId(), iNewItemId, EAknCtPopupFieldText, NULL );
CAknPopupFieldText* popupQuestion = static_cast<CAknPopupFieldText*>(popupControl);
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC(reader, R_POPUP_DYNAMIC_QUESTION);
popupQuestion->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy(2); //reader
Line(iNewItemId)->SetTakesEnterKey(ETrue);
Line(iNewItemId)->SetOfferHotKeys(ETrue);
//动态生成CAknPopupFieldText里显示的数组内容
CAknPopupField* popupField =popupQuestion;
int ncount=iContactDb->GetGroupCount();
iItemArray = new (ELeave) CDesCArrayFlat(ncount);
for(int i=0;i<ncount;i++)
{
iItemArray->AppendL(iContactDb->GetGroupAt(i));
}
iTextArray = CAknQueryValueTextArray::NewL();
iTextArray->SetArray( *iItemArray );
iQueryValText = CAknQueryValueText::NewL();
iQueryValText->SetArrayL( iTextArray );
iQueryValText->SetCurrentValueIndex( 0 );
popupField->SetQueryValueL( iQueryValText );
iNewItemId++;
4、在析构函数中删除动态生成的内容
if(iItemArray)
{
iItemArray->Reset();
delete iItemArray;
iItemArray=NULL;
}
if(iTextArray)
{
delete iTextArray;
iTextArray=NULL;
}
if(iQueryValText)
{
delete iQueryValText;
iQueryValText=NULL;
}
5、读取相关选择时可使用
HBufC* buf=iQueryValText->CurrentValueTextLC();
6、如果只需要动态生成控件,而不需要动态生成里边显示的数组时,可把数组在资源文件中定义,在PreLayoutDynInitL()中加下边一段代码即可
HBufC* buftemp=StringLoader::LoadLC(QTN_NAVI_LABEL_CONTACTGROUPVIEW);
CCoeControl* popupControl = CreateLineByTypeL(*buftemp, ActivePageId(), iNewItemId, EAknCtPopupFieldText, NULL );
CAknPopupFieldText* popupQuestion = static_cast<CAknPopupFieldText*>(popupControl);
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC(reader, R_POPUP_DYNAMIC_QUESTION);
popupQuestion->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy(2); //reader
Line(iNewItemId)->SetTakesEnterKey(ETrue);
Line(iNewItemId)->SetOfferHotKeys(ETrue);
1、定义资源文件
RESOURCE ARRAY r_settings_choice_std
{
items =
{
LBUF
{
txt = qtn_appl_test;
},
LBUF
{
txt=qtn_appl_help;
}
};
}
RESOURCE POPUP_FIELD_TEXT r_popup_dynamic_question {
popupfield = POPUP_FIELD {
width = 10;
};
textarray = r_settings_choice_std;
active = 0;
}
2、在CAknForm字类中增加变量
CDesCArray *iItemArray;
CAknQueryValueTextArray *iTextArray;
CAknQueryValueText *iQueryValText;
3、PreLayoutDynInitL()函数中增加以下代码
//增加一个CAknPopupFieldText控件
HBufC* buftemp=StringLoader::LoadLC(QTN_NAVI_LABEL_CONTACTGROUPVIEW);
CCoeControl* popupControl = CreateLineByTypeL(*buftemp, ActivePageId(), iNewItemId, EAknCtPopupFieldText, NULL );
CAknPopupFieldText* popupQuestion = static_cast<CAknPopupFieldText*>(popupControl);
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC(reader, R_POPUP_DYNAMIC_QUESTION);
popupQuestion->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy(2); //reader
Line(iNewItemId)->SetTakesEnterKey(ETrue);
Line(iNewItemId)->SetOfferHotKeys(ETrue);
//动态生成CAknPopupFieldText里显示的数组内容
CAknPopupField* popupField =popupQuestion;
int ncount=iContactDb->GetGroupCount();
iItemArray = new (ELeave) CDesCArrayFlat(ncount);
for(int i=0;i<ncount;i++)
{
iItemArray->AppendL(iContactDb->GetGroupAt(i));
}
iTextArray = CAknQueryValueTextArray::NewL();
iTextArray->SetArray( *iItemArray );
iQueryValText = CAknQueryValueText::NewL();
iQueryValText->SetArrayL( iTextArray );
iQueryValText->SetCurrentValueIndex( 0 );
popupField->SetQueryValueL( iQueryValText );
iNewItemId++;
4、在析构函数中删除动态生成的内容
if(iItemArray)
{
iItemArray->Reset();
delete iItemArray;
iItemArray=NULL;
}
if(iTextArray)
{
delete iTextArray;
iTextArray=NULL;
}
if(iQueryValText)
{
delete iQueryValText;
iQueryValText=NULL;
}
5、读取相关选择时可使用
HBufC* buf=iQueryValText->CurrentValueTextLC();
6、如果只需要动态生成控件,而不需要动态生成里边显示的数组时,可把数组在资源文件中定义,在PreLayoutDynInitL()中加下边一段代码即可
HBufC* buftemp=StringLoader::LoadLC(QTN_NAVI_LABEL_CONTACTGROUPVIEW);
CCoeControl* popupControl = CreateLineByTypeL(*buftemp, ActivePageId(), iNewItemId, EAknCtPopupFieldText, NULL );
CAknPopupFieldText* popupQuestion = static_cast<CAknPopupFieldText*>(popupControl);
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC(reader, R_POPUP_DYNAMIC_QUESTION);
popupQuestion->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy(2); //reader
Line(iNewItemId)->SetTakesEnterKey(ETrue);
Line(iNewItemId)->SetOfferHotKeys(ETrue);
相关文章推荐
- ExtJS 动态增加与删除items,动态设置textField可见与否
- SharePoint:扩展DVWP - 第7部分:创建一个列表表单操作并挂接工作流
- Javascript/Jquery操作数组,增删改查以及动态创建HTML元素
- 如何动态增加下拉框列表,下拉框里的内容从js数组里得来?
- 结构struct动态数组创建与操作
- ExtJS 动态增加与删除items,动态设置textField可见与否
- 结构struct动态数组创建、操作、删除
- js中对arry数组的各种操作小结 瀑布流AJAX无刷新加载数据列表--当页面滚动到Id时再继续加载数据 web前端url传递值 js加密解密 HTML中让表单input等文本框为只读不可编辑的方法 js监听用户的键盘敲击事件,兼容各大主流浏览器 HTML特殊字符
- Javascript/Jquery操作数组,增删改查以及动态创建HTML元素
- Javascript/Jquery操作数组,增删改查以及动态创建HTML元素
- 关于动态数组指针操作的两个例子
- 动态创建数组
- 创建动态数组
- C++ Primer 创建动态数组
- jquery 动态增加,减少input表单的简单方法(必看)
- 04——javascript Dom 动态创建元素 操作样式
- java-基础入门-泛型数组列表-解决运行时动态更改数组的问题
- java创建各种数组jvm默认初始值列表
- 动态创建多维数组
- .net,C#,Ftp各种操作,上传,下载,删除文件,创建目录,删除目录,获得文件列表...