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

Page down in Appium
How can I verify that my application won't download to android which hasn't BLE
Connect android emulator installed on local machine to a virtual machine
E/CameraSource: Failed to start recording, received error: Function not implemented (-38)
TextInputLayout and AutoCompleteTextView
Submit multiple forms with one button in android app?
Corona sdk display multi line notification
Removing user login button on Aviary Image Editor
Reverse Engineering Native Apps by Intercepting Network Traffic With Charles 4?
Android thread memory Leak
Not getting proper version code when using both split by abi and density
How to get GPS co-ordinates of particular place from HERE map
Play NSData or byte array form video from iOS and Android in HTML video tag
opening activity of module from main project
Ongoing Notification Disappears When Clearing Memory from the device in android?
setCharacteristicNotification doesn't trigger onCharacteristicChanged

Categories

HOME
phantom-dsl
grok
gdb
c++11
grafana
newrelic
switch-statement
telegram-bot
boto3
joomla3.0
endeca
mod-security
ycsb
qsqlquery
atlassian-stash
easyphp
google-container-registry
sigma.js
kendo-mobile
libigl
string-concatenation
monit
strongname
windows-server-2003
licensing
sqsh
testcomplete
finagle
cognos-bi
clickjacking
joomla2.5
numpy-broadcasting
openerp-7
salesforce-communities
playframework-2.1
watchman
verifiable-c
hackintosh
mcustomscrollbar
bindingnavigator
outputcache
xmldocument
puredata
jboss-4.2.x
ntvs
fclose
dbcontext
zenhub
ngmaterial
arules
usart
angular2-testing
adafruit
mongodb-php
cda
uiactionsheet
toast
dllimport
wiredep
mod-proxy
uncompress
baasbox
ocra
canvg
node-serialport
j-security-check
gii
insight.database
xml-dsig
winginx
dot42
bin
dtmf
scringo
ui-select2
kaleidoscope
cardreader
wimax
web-notifications
jdb
rmdir
cuteeditor
metaweblog
delimited-text
isapi-extension
todos

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