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

how to avoid ClassCast Exception
Pagination using retrofit to fetch next 10 items from API on scrolling in android
Live stream from Android app to Youtube channel
Show result JSON Parse to Custom Listview with Section
How to customize Material Calendar according to requirement?
How to use ZXingScannerFragment in PageRenderer
How to make a service unique which is defined in library
ListView is pushing up when keyboard popups
relativelayout inside radio group
Mount System parition from shell script not working in OTA package
Saving user credentials from google sign in with Android?
INSTALL_PARSE_FAILED_MANIFEST_MALFORMED in android
ACTION_CALL is not working in mobile but it is working in emulator
SSLhandshakeException in Jmeter:Recevied fatal alert:certificate_unknown
What is the best approach to upload 1000+ records to a server that also contains images for each record from an iOS/Android app?
How to access Firebase Database node using contains() method?

Categories

HOME
shell
github-for-windows
depth
themes
pascal
devise
nsbundle
telegram-bot
pyqt4
frontend
special-characters
elasticsearch-5
accessibility
syntaxnet
little-proxy
endpoint
plink
google-content-api
jersey-1.0
topology
symbols
drive
mongoid6
scriptella
dynamically-generated
xunit
data.stackexchange.com
jackson-modules
linked-data
inversion-of-control
tpm
failover
playstation-portable
dsx-desktop
gojs
git-rewrite-history
filesystemwatcher
recurrent-neural-network
verifiable-c
skylink
branching-and-merging
signal-strength
httr
plan-9
wcftestclient
identification
appdomain
context-sensitive-grammar
compiler-design
skin
er-diagram
django-1.10
sandcastle
restore
change-tracking
mapxtreme
autosar
burrows-wheeler-transform
watch-os-2
cifilter
simevents
spreadjs
fuzzywuzzy
toast
gocql
computer-architecture
lazybones
poppler
page.js
.bash-profile
sony-lifelog-api
batik
ocra
skspritenode
keyup
canvg
snoop
public-html
boost-program-options
addressing-mode
machine-instruction
strawberry-perl
buffering
multiautocompletetextview
mt4j
route-provider
dolby-audio-api
octal
jquery-1.9
resource-management
idn
intersect
curb
android-loadermanager
web-farm
appjs
w3c-geolocation
codebase
load-time
maven-1
drupal-fivestar
hbm2java
web-garden
application-verifier
wordprocessingml
interop-domino
sifr3
application-planning
sqlobject
technical-debt
appliance
idatareader

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