开发者

Titanium: navigation from one screen to other

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


 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


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;


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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜