Titanium: navigation from one screen to other

好久不见. 提交于 2020-01-12 10:48:42

问题


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();              
});

回答1:


 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




回答2:


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;




回答3:


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:


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


来源:https://stackoverflow.com/questions/5450075/titanium-navigation-from-one-screen-to-other

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!