pokoso
pokoso

Reputation: 1057

Add window to Activity created by Titanium Module

I made a Activity using Titanium Mobile Module, and it has simple white background.

Can I pass a window (Titanium object) from this Activity to another js files to add (draw) new objects (like buttons) ?

Upvotes: 0

Views: 44

Answers (1)

Victor Casé
Victor Casé

Reputation: 745

Yes, you can.

If you are using Alloy for it, just do anything similar as

//index.js
function doClick(e) {
    require('utils').createButton($.index);
}

And

//utils.js inside /lib
exports.createButton = function createButton(window){
     var button = Ti.UI.createButton({
          height:'20dp',
          width:'20dp',
          title:'Test'
     });
     window.add(button);
 }

However, keep in mind, to your memory consumption, because you are sending a big object $.index as a local variable.

Upvotes: 2

Related Questions