Titanium 如何在alloy xml中处理视图的动态创建
我有一个非常简单的view index.xmlTitanium 如何在alloy xml中处理视图的动态创建,titanium,titanium-alloy,Titanium,Titanium Alloy,我有一个非常简单的view index.xml <Alloy> <Window id="byFav"> <TableView id="tableByFav" /> </Window> <Alloy> 然而,我不确定它是否遵循合金的概念 我试图理解合金的概念。您打开的窗口不正确,请尝试以下方法: $.tableByFav.addEventlistener('click',function(e){
<Alloy>
<Window id="byFav">
<TableView id="tableByFav" />
</Window>
<Alloy>
然而,我不确定它是否遵循合金的概念
我试图理解合金的概念。您打开的窗口不正确,请尝试以下方法:
$.tableByFav.addEventlistener('click',function(e){
var entryWindow = Titanium.UI.createWindow({
title: "window"
});
var entryView = Titanium.UI.createWebView({
url: "http://www.google.com"
});
entryWindow.add( entryView );
// Call open on the entry window itself
entryWindow.open({
modal : true // Set to true if you want an opening animation
});
}
要使用Alloy执行此操作,您可以为名为(entryWindow.xml
)的webview创建一个控制器,如下所示:
<Alloy>
<Window id="entryWindow">
<WebView id="entryView" />
</Window>
<Alloy>
$.tableByFav.addEventlistener('click',function(e){
// Create a controller, pass url argument
var controller = Alloy.createController('entryWindow', {url: "http://www.google.com"});
// Get the controller's view (a window) and open it
controller.getView().open({
modal : true // Set to true if you want an opening animation
});
}
现在,在索引控制器中,您可以如下方式打开webview:
<Alloy>
<Window id="entryWindow">
<WebView id="entryView" />
</Window>
<Alloy>
$.tableByFav.addEventlistener('click',function(e){
// Create a controller, pass url argument
var controller = Alloy.createController('entryWindow', {url: "http://www.google.com"});
// Get the controller's view (a window) and open it
controller.getView().open({
modal : true // Set to true if you want an opening animation
});
}