Titanium: navigation from one screen to other

2019-04-03 01:33发布

On the click of my button, I want to navigate to another screen. How would I achieve this in Titanium?

var TrialButton = Titanium.UI.createButton({
    color:'black',
    backgroundColor:'#FFFFFF',
    title:'Trial Mode',
    top:55,
    width:300,
    height:50,
    borderRadius:5,
    font:{fontSize:18, fontFamily :'Helvetica', fontWeight:'bold'}
});



 TrialButton.addEventListener('click', function() {    
  var newWindow = Titanium.UI.createWindow({ 
      background : "#fff",
      title : "Trial Demo",           
      url:"nextScreen.js"    
  });    
  newWindow.open();              
});

4条回答
Deceive 欺骗
2楼-- · 2019-04-03 01:52

Because its written wrong. Theres an error in code at the last line. The ")" has to follow after "}". Not opposite ast written here. So the closing tag is right like this: "});". Use following code instead:

TrialButton.addEventListener('click', function()
 {
    var newWindow = Ti.UI.createWindow({
       background : "#000",
    title : "Image View",
        url:"nextScreen.js"
    });
    newWindow.open();
   //close your current window of this page and also in your nextScreen.js page, the window must be set to current window         
 });
查看更多
虎瘦雄心在
3楼-- · 2019-04-03 02:01
TrialButton.addEventListener('click', function()
 {
    var newWindow = Ti.UI.createWindow({
        background : "#000",
        title : "Image View",
        url:"nextScreen.js"
    });
    newWindow.open();
    //close your current window of this page and also in your nextScreen.js page, the window must be set to current window         
 )};
查看更多
啃猪蹄的小仙女
4楼-- · 2019-04-03 02:02

If you're using Alloy, You can also navigate to another screen using the Alloy.createController method.

function sample(e) {

var nextScreen = Alloy.createController('nameOfNextScreen').getView();

nextScreen.open();

}

If you wish, you can also pass data to the next screen by passing it in as an argument eg,

var nextScreen = Alloy.createController('nameOfNextScreen', {sushi: "california roll" }).getView();

and retrieving the argument in the next screen with the following

var args = $.args;

var value = args.sushi;

查看更多
聊天终结者
5楼-- · 2019-04-03 02:14
 TrialButton.addEventListener('click', function()
 {
    var newWindow = Ti.UI.createWindow({
        background : "#000",
        title : "Image View",
        url:"nextScreen.js"
    });
    newWindow.open();             
 )};

should checkout examples here https://github.com/appcelerator/KitchenSink

here are some posts from my blog http://blog.clearlyinnovative.com/tagged/Appcelerator

查看更多
登录 后发表回答