Skip to content

Instantly share code, notes, and snippets.

Created October 22, 2010 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/46ff47010948f9d8f506 to your computer and use it in GitHub Desktop.
Save anonymous/46ff47010948f9d8f506 to your computer and use it in GitHub Desktop.
var win = Titanium.UI.currentWindow;
var view0 = Titanium.UI.createView({backgroundColor:'#123'});
var text0 = Ti.UI.createLabel({
text:"view 0",
width:"auto",
height:"auto",
top:10
});
view0.add(text0);
var b0 = Ti.UI.createButton({
height:40,
width:200,
title:'Remove/Add View 2',
top:140
});
view0.add(b0);
var b1 = Ti.UI.createButton({
height:40,
width:200,
title:'Remove View 2',
top:200
});
view0.add(b1);
var b2 = Ti.UI.createButton({
height:40,
width:200,
title:'Remove View with no target',
top:260
});
view0.add(b2);
var view1 = Titanium.UI.createView({backgroundColor:'#456'});
var text1 = Ti.UI.createLabel({
text:"view 1",
width:"auto",
height:"auto",
top:10
});
view1.add(text1);
var view2 = Titanium.UI.createView({backgroundColor:'#789'});
var text2 = Ti.UI.createLabel({
text:"view 2",
width:"auto",
height:"auto",
top:10
});
view2.add(text2);
var state = true;
b0.addEventListener('click', function()
{
if(state){
scrollableView.removeView(view2);
Ti.API.info('view 2 removed');
state = false;
} else {
scrollableView.addView(view2);
Ti.API.info('view 2 added');
state = true;
}
});
var removeNumber = 0;
b1.addEventListener('click', function()
{
scrollableView.removeView(view2);
removeNumber++;
state = false;
Ti.API.info('removing view 2 for time: '+removeNumber);
});
b2.addEventListener('click', function()
{
scrollableView.removeView();
Ti.API.info('removing view without target');
});
var scrollableView = Titanium.UI.createScrollableView({
views:[view0,view1,view2]
});
scrollableView.addEventListener('scroll', function(e){
Ti.API.info('***************************************');
Ti.API.info('scrollable view scroll currentPage: '+e.currentPage);
});
win.add(scrollableView);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment