【问题标题】:Drawer widget Titanium alloy抽屉小部件 钛合金
【发布时间】:2014-04-08 14:48:05
【问题描述】:

我是 Titanium 的新手,我想放置一个抽屉小部件,但小部件没有出现。有人告诉我为什么和解决方案?谢谢。

这是我的课程:

index.xml

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

这是 de 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();

【问题讨论】:

    标签: javascript android ios titanium drawer


    【解决方案1】:

    实际上,您在另一个窗口中添加了小部件,并且您在 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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多