Posts

Showing posts from April, 2012

Titanium Appcelerator - Android TableView Index Out Of Bound

This only happen in Android. If you create a TableView with a attribute className: "SomeThing", you will encounter java.lang.ArrayIndexOutOfBoundsException when you hit a back button. Based on that java exception, you will have no clue on what is happen especially the same code work for iPhone
Simply remove the className attribute and you are good to go!!

Titanium Appcelerator - Picker setSelectedRow

Although in some post, they said that Picker.setSelectedRow is bugged, I think otherwise.

In the API, it is said that setSelectRow must be called after the picker is displayed. Display means the picker must be rendered and the best case to use it is after calling Window.open().

Thus, 2 ways to use it

First way

var win = Ti.UI.createWindow({  //... add some configuration  });
var picker = Ti.UI.createPicker({  //... add some configuration  });
//... add some data....
win.add(picker);
win.open();
//setting to column 0, row 1, with no animation
picker.setSelectedRow(0, 1, false);

Second way is to put setSelectedRow in window open event

var picker = null;

function Foo(){

   var win = Ti.UI.createWindow({  //... add some configuration  });
   picker = Ti.UI.createPicker({  //... add some configuration  });
   //... add some data....
   win.add(picker);
   win.addEventListener("open", onOpen);    win.open(); }
function onOpen(){    //setting to column 0, row 1, with no animation

Titanium Appcelerator - iOS Toolbar Button Alignment

Image
Somehow, UI alignment is always a problem for me. Today, it is about UI button alignment in iOS toolbar.

Below piece of code create iOS specific button that is only displayable in toolbar



Those system button feature is a nice and simple code that create iOS button style.

self is a Titanium.Window create with var self = Titanium.UI.createWindow();

self.toolbar access the inner toolbar component and set the five buttons into it. However, the outcome will be as follow



Those buttons are fully left aligned and not equally space. To make equally spaced button, you need to use a system button call FLEXIBLE_SPACE. Below is the modified code

As you can see, I added flexSpace in between each playback button and the result will be as followed.