Create a toolbar with buttons
I am trying to create a simple application with just a webview at the top and a toolbar at the bottom. I can add both the webview and toolbar but can not add buttons into the toolbar. I would appreciate if anybody can help me?
`var webView = Titanium.UI.createWebView({
url:'http://google.com',
width:320,
height:416,
left:0,
top:0
});
//var aSimpleBarButton = Titanium.UI.createBarButton({
//});
//
//var aSimpleButton = Titanium.UI.createButton({
//
//});
var webToolbar = Titanium.UI.createToolbar({
center:{
x:0,
y:440
}
});
//webToolbar.add(aSimpleButton);
//webToolbar.add(aSimpleButton);
win1.add(webToolbar);
win1.add(webView);
win1.open();`
I try to add either barbutton or button into the toolbar but the iphone simulator just crashed
1 Answer
-
when creating a toolbar you add the buttons in an array, See excerpt from KitchenSInk windows_toolbar.js
var b = Titanium.UI.createButton({ title:'Button', style:Titanium.UI.iPhone.SystemButtonStyle.DONE }); var flexSpace = Titanium.UI.createButton({ systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE }); b.addEventListener('click', function() { Ti.API.info('Clicked right button!'); }); win.setToolbar([flexSpace,b]);