据我了解(刚开始学习SDK),你不能这样做。您可以通过编写html文件在应用程序包中定义自己的窗口,通过使用Ti.UI对象打开它并使用Ti.Network命名空间的HTTPCLient获取外部HTML内容。通过这种方式,你可以加载所需的HTML内容或其他类似JSON,并将其植入到你的窗口HTML DOM中。
例子:
首先,你要使用你自己的HTML文件中创建一个新的窗口:
Ti.UI.createWindow("app://special-window.html")
在该文件中,可以执行一些Javascript来获得一些外部的资源,如HTML:
//Request URL
var url = 'http://mywebsite.com/api/users/';
//Create the HTTP Client
var client = Ti.Network.createHTTPClient({
onload: function(e) {
//request complete do something with data
//assuming that we are not working with XML
Ti.API.INFO('Response received '+this.responseText);
// DO SOMETHING WITH THE this.responseText HERE (like adding it to your DOM)
},
onerror: function(e) {
//error received, do something
}
});
//Specify request type and open
client.open('GET',url);
//Send request
client.send();
该代码取自文档。 (正如我所说,我刚开始使用SDK)
希望,我可以帮助一下:)