开始活动+背景图片Titanium

时间:2012-08-08 10:52:26

标签: javascript android iphone titanium-mobile

我正在使用Titanium创建一个iPhone / Android应用程序。我有2个js文件 1. app.js 2.rss.js

在app.js中,我编写了以下代码: -

      if(Titanium.Platform.name != 'android'){
    var rssWindow = Titanium.UI.createWindow(
        {
            url : "rss.js",
            title : "RSS FEEDS",
            barColor:'#0f0f0f',
            backgroundImage:'images/Background.png'
        });
    navigation.open(rssWindow,{animated:true});
  }
  else{
    var intent = Ti.Android.createIntent({
            url: 'rss.js',
    });
    intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
    Ti.Android.currentActivity.startActivity(intent);
}

此代码正确地将我带到rss.js但在rss.js中,当我尝试设置当前窗口的背景图像时,应用程序在Android中运行时崩溃,而它在Iphone中正确运行。

rss.js

      if(Titanium.Platform.name == 'android')
          var activity = Ti.Android.currentActivity;
      var win = Titanium.UI.currentWindow;
      Titanium.API.info('RSS screen loaded');
      win.backgroundImage = 'images/Background.png'

有没有人能解决这个问题,或者我做错了什么。 图像路径已经过检查并且正确无误。

1 个答案:

答案 0 :(得分:0)

我还没有在i-phone上查看我的应用程序但是,我的应用程序中也遇到了类似的意外关闭问题..

问题与在Titanium中设置Window的背景属性有关。 此属性最多可以titanium sdk 1.7.5 *

但之后就崩溃了。

我只是厌倦了解决将图像设置为背景的技巧..

刚刚创建了视图

var WindowBackground = Ti.UI.createView({

         backgroundImage:'../../Images/General/SelectedimageforBackground.png'

    });

并在窗口中显示所有控件之前将其添加到窗口。 结果与所需内容相同..

* you can check the sdk in your Tiapp.xml