Hi,
How to create a common module for activity indicator using exports in some file and use it through require('relative path').func() to call hide/show methods, wherever its required through out the app. Instead of using Ti.App.fireEvent or Ti.include('activity.js') in all files, how to achieve a common module which can be effectively used in Ipad/iphone. help me out with a snippet.
2 Answers
This is how I'm using it. Any suggestion is welcome.
utilities.js :
function loadingWindow() { // window container var self = Ti.UI.createWindow({ height:80, width:200, touchEnabled:false }); var activityIndicator = Ti.UI.createActivityIndicator({ message : L("loading_data"), color : 'white', height : 50, width : 10, font : {fontSize:18,fontWeight:'bold'}, touchEnabled:false }); activityIndicator.show(); var transparentView = Ti.UI.createView({ height:80, width:200, backgroundColor:'#000', borderRadius:10, opacity:0.75, touchEnabled:false }); self.add(transparentView); self.add(activityIndicator); return self; }; exports.loadingWindow = loadingWindow;And to use it
var loadingWindow = utilities.loadingWindow();The Loading window will be shown immediately.
So, when you want to hide it you need to use:
loadingWindow.hide();And whenever you need to show it again.
loadingWindow.show();I hope that helps.
25
Your Answer
Think you can help? Login to answer this question!