【发布时间】:2014-10-10 10:24:01
【问题描述】:
我有 3 个合金屏幕(加速器):
index.xml
<Alloy>
<Window class="container">
<ImageView id = "actor" image="/images/f_logo.jpg"></ImageView>
<Label id = "bienvenue" onClick="doClick" > Bienvenue </Label>
<Label id = "apropos"> A propos </Label>
</Window>
</Alloy>
welcome.xml
<Alloy>
<Window class = "win2container">
<ImageView id = "bienvenue2" image="/images/f_logo.jpg"></ImageView>
<View id="texte" onClick="showTable">
<Label text="Afficher la liste" ></Label>
</View>
</Window>
</Alloy>
liste.xml
<Alloy>
<Tab title="Basic">
<Window title="Basic">
<ListView id = "liste" itemClick="onItemClick">
<ListSection>
<ListItem title="Row 1"></ListItem>
<ListItem title="Row 2"></ListItem>
<ListItem title="Row 3"></ListItem>
<ListItem title="Row 4"></ListItem>
<ListItem title="Row 5"></ListItem>
<ListItem title="Row 6"></ListItem>
<ListItem title="Row 7"></ListItem>
<ListItem title="Row 8"></ListItem>
<ListItem title="Row 9"></ListItem>
<ListItem title="Row 10"></ListItem>
<ListItem title="Row 11"></ListItem>
<ListItem title="Row 12"></ListItem>
</ListSection>
</ListView>
</Window>
</Tab>
</Alloy>
index.js(有效)
function doClick(e) {
var win = Alloy.createController("welcome").getView();
win.open();
}
$.index.open();
welcome.js(我要打开列表窗口)
function showTable(e){
var liste = Alloy.createController("liste");
liste.getView().open();
}
当我点击索引标签时,它会打开欢迎窗口,当我点击欢迎视图时它什么也不做,我的目标是发现如何使用合金在许多窗口(查看文件)之间导航。
其次,我在 google 上看到,像这样关闭以前的窗口是一个好习惯:
$.win.close();
$.win = null;
当我在 $.win.open() 之后将此代码放入 index.js 时,它不起作用(即:我出错了)
function doClick(e) {
var win = Alloy.createController("bienvenue").getView();
win.open();
$.win.close(); // or win.close() ?
$.win = null; // or win = null ?
}
有什么建议吗?我试了很多次都没有成功。
谢谢大家。
【问题讨论】:
标签: view window titanium appcelerator