如何在Kony中创建CustomViews?

时间:2014-05-29 09:12:04

标签: kony

如何在kony中的运行时创建自定义视图。例如在android中我们创建一个像

这样的按钮
Button mBtn = new Button(activity.getApplicationContext());

同样在kony如何创建一个视图,Textfiled,按钮在kony。

1 个答案:

答案 0 :(得分:1)

要创建动态视图,您需要设置表单的属性

//Form basic configuration
var basicConf = {
    id:"frmDynamic",
    postShow:ShowPostShowAlert
};

//Form layout configuration
var layoutConf = {
    displayOrientation:"FORM_DISPLAY_ORIENTATION_PORTRAIT",
    padding:[5,5,5,5],
    paddingInPixel:true
};

//Form Platform Specific Properties configuration
var platformConf = {
    onDeviceBack:ShowOnBackAlert
};

获得所有属性后,创建Form2的实例并分配您创建的属性

//Create the form
var frmDynamic = new kony.ui.Form2(basicConf, layoutConf, platformConf);

让我们在您的表单中添加一个文本框。就像表单一样,您需要设置文本框的属性

//Textbox Basic Configuration
var textboxBC = {
    id:"txtDynamic",
    isVisible:true,
    placeholder:"Type here..."
};

//Textbox Layout Configuration
var textboxLC = {
    hExpand:true,
    margin:[2,2,2,2],
    padding:[0,0,0,0],
    marginInPixel:true,
    paddingInPixel:true
};

//Textbox Platform Specific Properties Configuration
var textboxPC = {
    toolTip:"Dynamic TextBox"
};

创建TextBox2的实例

//Create the Textbox
var txtDynamic = new kony.ui.TextBox2(textboxBC textboxLC, textboxPC);

现在在表单中添加文本框并显示表单

frmDynamic.add(txtDynamic);
frmDynamic.show();

希望它有所帮助。

相关问题