1

How to create custom view in run time in kony.For example in android we create a button like

Button mBtn = new Button(activity.getApplicationContext());

similarly in kony how to create a view,Textfiled,Buttons in kony.

Yuvaraja
  • 715
  • 6
  • 22
  • 2
    You can create widgets with call like new kony.ui.box(..) and the nadd it to containers using container_var.add(theButton). Kony widget user guide will have further information on individual components. – Paddy May 30 '14 at 20:08
  • I had added more details to the answer, which got deleted (due to race conditions :-) ). So, if you have access to the deleted answer, you can check it out. – Paddy Jun 16 '14 at 17:08

1 Answers1

1

To create a dynamic view, you need to set the properties for your Form

//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
};

Once you have all the properties, create an instance of Form2 and assign the properties that you created

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

Let's add a textbox into your Form. Just like the form, you need to set the properties for your textbox

//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"
};

Create the instance of TextBox2

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

Now add the textbox in the form and show your Form

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

Hope it helps.