2014-04-08 144 views
0

我是钛合金新手,我想放置一个抽屉工具,但不显示工具。 Soemeone告诉我为什么和解决方案?谢谢。抽屉部件钛合金

这里是我的课:

INDEX.XML

<Alloy> 
    <Window class="container"> 
     <Require type="widget" src="com.appcelerator.drawer" id="drawer" /> 
    </Window> 
</Alloy> 

这是德JavaScript类。

index.js

var principal = Ti.UI.createWindow({ 
    fullscreen : true, 
    navBarHidden : true 
}); 

var boton1 = Ti.UI.createButton({ 
    zIndex : 0, 
    width : "33%", 

    height : "50%", 
    top : 0, 
    left : 0 
}); 
var boton2 = Ti.UI.createButton({ 
    zIndex : 0, 
    width : "34%", 
    height : "50%", 
    top : 0, 
    center : true 
}); 

var boton3 = Ti.UI.createButton({ 
    zIndex : 0, 
    width : "33%", 
    height : "50%", 
    top : 0, 
    right : 0 
}); 

principal.add(boton1); 
principal.add(boton2); 
principal.add(boton3); 

$.drawer.init({ 
    mainWindow : principal, 
    buttons : [{ 
     id : 'One', 
     title : 'One', 
     backgroundcolor : "white", 
     click : function(e) { 
      alert("One"); 
     } 
    }], 
    gutter : 5, 
    overrideMenu : true 
}); 

principal.open(); 

回答

0

其实你在另一个窗口小部件添加和你逝去的另一个窗口对象index.js文件,所以只能使用一个窗口。

INDEX.XML

<Alloy> 
    <Window class="container" id="principal"> 
     <Require type="widget" src="com.appcelerator.drawer" id="drawer" /> 
    </Window> 
</Alloy> 

index.js

$.drawer.init({ 
    mainWindow : $.principal, 
    buttons : [{ 
     id : 'One', 
     title : 'One', 
     backgroundcolor : "white", 
     click : function(e) { 
      alert("One"); 
     } 
    }], 
    gutter : 5, 
    overrideMenu : true 
}); 

$.principal.open(); 
+0

它的工作原理!谢谢! – CandelSR