android


Titanium : Application showing main contents on splash screen instead of main window


I am new to appcelerator. I am following a tutorial, in which content should be on main window, but my code is showing main content on splash screen. When I press back key, it shows the main window but without content.
Here is my main window code.
var win = Ti.UI.currentWindow;
//-- Create the sub windows
var crusts = Ti.UI.createWindow();
var toppings = Ti.UI.createWindow();
var details = Ti.UI.createWindow();
//-- We set the background here since this wont change
win.backgroundImage = '../images/bg_main.png';
//-- Include our clock
Ti.include('../includes/clock.js');
//-- The method will close the toppings window and open the crusts window
function openCrust(e) {
crusts.url = 'crusts.js';
crusts.open();
Ti.Ti.API.log('info', 'openCrust Called.');
}
openCrust({});
Here crust.js is main content window and its code is.
var win = Ti.UI.currentWindow;
//-- Our crust views
var handMade = Ti.UI.createView({width:216,height:156,backgroundImage:'../images/crust/hand.png'});
var natural = Ti.UI.createView({width:216,height:156,backgroundImage:'../images/crust/natural.png'});
var panCrust = Ti.UI.createView({width:216,height:156,backgroundImage:'../images/crust/pan.png'});
var stuffedCrust = Ti.UI.createView({width:216,height:156,backgroundImage:'../images/crust/stuffedCrust.png'});
var thinNCrispy = Ti.UI.createView({width:216,height:156,backgroundImage:'../images/crust/thinNcrispy.png'});
var returnCrust;
//-- Crust reference
var crusts = [
{title:'Hand Made',path:'../images/crust/hand.png'},
{title:'Natural',path:'../images/crust/natural.png'},
{title:'Pan Crust',path:'../images/crust/pan.png'},
{title:'Stuffed Crust',path:'../images/crust/stuffedCrust.png'},
{title:'Thin N Crispy Crust',path:'../images/crust/thinNcrispy.png'}
];
//-- Our scroll view that contains our crust views
var scrollView = Ti.UI.createScrollableView({
views:[handMade,natural,panCrust,stuffedCrust,thinNCrispy],
showPagingControl:true,
clipViews:false,
top:180,
left:30,
right:30,
height:180,
opacity:0
});
//-- Crust title
var crustTitle = Ti.UI.createLabel({
text:'1. Choose a crust',
font:{
fontFamily:'Verdana',
fontWeight:'bold',
fontSize:24
},
color:'#A90329',
shadowColor:'#333',
shadowOffset:{x:1,y:1},
textAlign:'left',
width:Ti.Platform.displayCaps.platformWidth,
height:58,
left:10
});
//-- Crust title background
var crustTitleView = Ti.UI.createView({
width:328,
height:58,
backgroundImage:'../images/crustHeaderBg.png',
top:100,
left:-6,
opacity:0
});
crustTitleView.add(crustTitle);
//-- Crust type label
var crustType = Ti.UI.createLabel({
text:'Hand Made',
font:{
fontFamily:'Verdana',
fontWeight:'bold',
fontSize:16
},
color:'#fff',
shadowColor:'#333',
shadowOffset:{x:1,y:1},
textAlign:'center',
width:Ti.Platform.displayCaps.platformWidth,
height:20,
top:170,
opacity:0
});
//-- Next Button
var next = Ti.UI.createButton({
width:137,
height:75,
backgroundImage:'../images/toppings_next.png',
top:385,
opacity:0
});
//-- If android OS, use the image property instead of backgroundImage (Ti SDK bug)
if (Ti.Platform.osname == 'android')
{
next.image = '../images/toppings_next.png';
}
next.addEventListener('click',function(e){
Ti.App.fireEvent('toppings',{
crust:crusts[scrollView.currentPage].title,
path:crusts[scrollView.currentPage].path
});
});
win.add(scrollView);
win.add(crustTitleView);
win.add(crustType);
win.add(next);
//-- Fade the scrollview in
scrollView.animate({
opacity:1,
duration:500
});
//-- Fade the crust title in
crustTitleView.animate({
opacity:1,
duration:500
});
crustType.animate({
opacity:1,
duration:500
});
//-- Fade the next button in
next.animate({
opacity:1,
duration:500
});
//-- Changes the crust type label text when the user scrolls
scrollView.addEventListener('scroll',function(){
crustType.text = crusts[scrollView.currentPage].title;
});
Here is screenshots of results.
image with actual result: https://www.dropbox.com/s/m58pvx2dvde2xy7/actual%20result.png?dl=0
image with desired result : https://www.dropbox.com/s/dslr4ilgo8ro9yf/desired.jpg?dl=0
please tell me where i am getting wrong.
Thanks.
You can't reference an image with a path like ../images/XXX. /images is considered to be your root folder for the graphics resources.
Try to change the path to the window background
win.backgroundImage = '/images/bg_main.png';

Related Links

onResume for android annotations
The meta-data does not have the right value Google Maps v2 on Android API 10
CSS3 sliding image on hover, strange spacing
Webview HTML input type file in Android
java.net.UnknownHostException: Unable to resolve host “graph.facebook.com” when I run an Android Facebook app after closing emulator
How to disable the message on preview of Android Studio?
login with facebook in phonegap 4.2
android, layout null pointer exception :: no clear reason [duplicate]
Android: Frame animation on Swipe Gesture
Problems using and LDR to play Audio from SD card
Ionic BUILD FAILED when running “ionic run android”
In app billing issue
Android ListView click set all Checkboxs to enabled
Thread synchronization in android
Unable to build PlusClient with gradle (Android Studio)
Pro and cons calling finish

Categories

HOME
service-worker
windows
asp.net-web-api
kentico
microsoftgraph
cobalt
paraview
c++11
codenvy
css3
datastore
pyqt
toolbox
graphics
shiro
pclxl
onclick
android-json
p2p
syntaxnet
jxl
radgridview
intercom
atlassian-stash
video-editing
wolframalpha
blade
displaytag
interpreter
pylons
delimiter
ceylon
jaws
send
cart
jett
activexobject
reactjs.net
html-encode
pdw-file-browser
sql-delete
navigator
engine.io
watchman
plaintext
watchface
subclipse
xmldocument
vaadin-charts
dapper-simplecrud
nanoc
reshape
django-1.10
vcloud-director-rest-api
rocks
simplepie
atlas
microstation
async.js
vulcanize
wso2developerstudio
synonym
lua-telegram-bot
php-socket
gcloud-ruby
ascii-art
batik
viola-jones
uncompress
sha512
sql-server-data-tools
phpldapadmin
document-repository
browserify-shim
spy++
angular-carousel
draw2d-js
mutual-authentication
twitter-bootstrap-rails
menubar
gtm-oauth2
scrypt
inputmismatchexception
cnf
paginator
pinch
landscape-portrait
presentation-layer
facebook-iframe
jqueryform
tabpanel
scrollbars
lxr
fdf
firefox-3
flvplayback
soappy
lemmatization
contentpresenter

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App