Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

displaying Views on each button click on same window

$
0
0

Application Type : Mobile Titanium SDK Version:Titanium Studio, build: 3.1.0.201304151600 (c) Copyright 2012-2013 by Appcelerator, Inc. All rights reserved.

Build: jenkins-titanium-rcp-master-417 (origin/master) Date: 15 April 2013, 16:04:14

Platform:Android,IOS

I am creating a application which has a single window and on that window I have created 9 buttons and each button click has an associated event that opens upon the view and closes the previous displayed view on the window and displays only the current window

I am unable to close the previous view and display the current view ,I am testing it initially with 2 buttons and 2 views .

I have created the buttons using a for loop and the each event listener calls a function that handles the code to display the appropriate view

displayview(I) { //I is the index of the buttons.

if(I==0) { for(i=0;i<9;i++) { if(i!=I) { view[i].hide(); //Closes all other existing view }

} win.add(view[I]);/adds the correct view based on the index I

}

if(I==1) { for(i=0;i<9;i++) { if(i!=I) { view[i].hide(); //Closes all other existing view }

} win.add(view[I]);/adds the correct view based on the index I }

this function is called from the button event listener for(i=0;i<9;i++){ button[i].addEventListener('click', function (e) { I=e.source.id; Ti.API.info("Id is "+I); displayview(I); }); } //I think my logic is wrong Please help me on this


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>