Thursday, April 26, 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!!

Sunday, April 22, 2012

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

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....
//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.addEventListener("open", onOpen);;

function onOpen(){
   //setting to column 0, row 1, with no animation
   picker.setSelectedRow(0, 1, false);

Both way ensure picker.setSelectedRow(0, 1, false); is called after Window is opened

When setSelectedRow is use, a change event could be trigger if the there is a change in selected item.

One may think that on window open, picker.setSelectedRow will definitely trigger a change event because there is no selected item prior to window open. You are half correct because iPhone will trigger a change even while Android will not. Please take note of this.


Thursday, April 19, 2012

Titanium Appcelerator - iOS Toolbar Button Alignment

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.

Tomcat - removing server info

Below are the steps to remove Tomcat Server Information 1. Make sure Tomcat is not running 2. Navigate to "Tomcat Installation"...