【问题标题】:Titanium: navigation from one screen to otherTitanium:从一个屏幕导航到另一个屏幕
【发布时间】:2011-03-27 15:07:41
【问题描述】:

点击我的按钮后,我想导航到另一个屏幕。我将如何在 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();              
});

【问题讨论】:

    标签: android titanium


    【解决方案1】:
     TrialButton.addEventListener('click', function()
     {
        var newWindow = Ti.UI.createWindow({
            background : "#000",
            title : "Image View",
            url:"nextScreen.js"
        });
        newWindow.open();             
     )};
    

    应该在这里查看示例https://github.com/appcelerator/KitchenSink

    这是我博客http://blog.clearlyinnovative.com/tagged/Appcelerator的一些帖子

    【讨论】:

    • 我得到这个“未捕获的引用错误:模块未定义”似乎下一步很清楚,我需要定义 nextScreen 模块吗?
    【解决方案2】:

    如果您使用的是 Alloy,您还可以使用 Alloy.createController 方法导航到另一个屏幕。

    函数样本(e) {

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

    }

    如果您愿意,您还可以通过将数据作为参数传入来将数据传递到下一个屏幕,例如,

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

    并使用以下内容在下一个屏幕中检索参数

    var args = $.args;

    var 值 = 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】:

        因为它写错了。最后一行的代码有错误。 ")" 必须跟在 "}" 之后。不反对 ast 写在这里。所以结束标签是这样的:“});”。请改用以下代码:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2010-11-09
          • 2014-12-07
          • 1970-01-01
          • 2022-01-22
          • 2020-07-27
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多