High performance ListView scrolling

If you are experiencing performance issues while scrolling through a ListView in Android you might not have used the pattern for high performance ListView.

Every time you scroll the ListView, the method getView() gets called. If you scroll down 3 Lines this means that the metod gets called three times! This means you should do as least as possible in this metod!

Looking up Widgets in XML is a very expensive task since it needs to parse the xml in order to find the objects for each scrolled Row!

The solution is pretty simple:
1. Check if convertView has not been initialized yet and on initialize it only once.
2. Use a static holder class to hold the Views elements.
3. Only update the values of the holder class if getView is called after it already has been initialized.

This should result in a massive performance improvement. The follwing Code demonstrates this pattern:

public View getView(int position, View convertView, ViewGroup parent)
	LogRowHolder logRowHolder = null;
	if (convertView == null) // Only initialize the view if it didn't already happen
	    convertView = layoutInflater.inflate(R.layout.log_row, parent, false);   

            // Fill the Holder Object with the elements of the View
	    logRowHolder = new LogRowHolder();
	    logRowHolder.colorbar = (RelativeLayout) convertView.findViewById(;
	    logRowHolder.main_label = (TextView) convertView.findViewById(;
	    logRowHolder.picture_label = (TextView) convertView.findViewById(;
	    logRowHolder.picture_name_label = (TextView) convertView.findViewById(;

	    logRowHolder = (LogRowHolder) convertView.getTag();  

	LogRow row = items.get(position);
	if (row != null)


	return convertView;

* This simple class holds the objects of the view
static class LogRowHolder
	RelativeLayout colorbar = null;
	TextView main_label = null;
	TextView picture_label = null;
	TextView picture_name_label = null;



Developing Android Applications in NetBeans

Eclipse may be the IDE of choice for many and the standard development platform for Android applications but I could never really enjoy working with eclipse. Every other update it seems to break which forces me to reinstall and reconfigure it and waste a lot of time. I don’t know if I’m just to stupid to use the update function of Eclipse or if this happens regularly. Anyway I try to avoid Eclipse as much as possible to avoid wasting time on repairing my IDE.

My preferred IDE is NetBeans which does not come with Android support by default but the project NBAndroid fixes this issue by providing a very good plugin. Once installed the plugin provides everything needed to develop Android applications with NetBeans. The installation is pretty easy and documented here.

I have used this plugin for about a year now and I’m really pleased with it. But one thing should be considered when using this:
Updating the Android SDK to a new major version usually breaks the NBAndroid plugin. This is of course related with the changes in the SDK and the plugin gets updated pretty quickly. The last update of the Android SDK which added support for Android 4 took the developers of NBAndroid about a week to update the SDK.


Howto use Hibernate as a persistence provider in Glassfish

The Glassfish application server does’t come with Hibernate support by default but installing it is pretty easy.

Just launch the Glassfish Update Tool and select theĀ  Hibernate JPA Plugin.

This command launches the update tool:

After installing the plugin copy the database driver to this folder:

Then restart the application server and add your connection pool and the jndi.