Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Table views with Android - won't refresh data

I have an application that seems to work fine in the iPhone emulator, but I'm having serious trouble with it in the Android emulator (using the 2.1-upd SDK).

The code itself is rather simple. I'm using an Network.HTTPClient to go out and read an XML file on the web. On the object's onLoad event, I fill an array called "data" and then set the tableView to it.

Below is a simplified version of this code:

xhr.onload = function()  //Event handler for when XML is loaded into xhr object
    var tmpStockPrice;

    var doc       = this.responseXML.documentElement;

        coNameArr     = doc.getElementsByTagName("Company");
        stockPriceArr = doc.getElementsByTagName("StockPrice");

        for (i=intOffset; i <= intOffset + elements.length - 1; i++)
            var company    = coNameArr.item(i - intOffset);
            var stockPrice = stockPriceArr.item(i - intOffset);
            tmpStockPrice  = parseFloat(stockPrice.text);

            data[i] = {



For the search bar, I have a search click event as follows:

search.addEventListener('return', function(e)
    data = new Array();
    xhr.open('GET', strURL + '?search=' + search.value);

So basically, when they perform the search, I reset the HTTPClient (xhr) with a new URL that returns a subset of the data in XML. The onLoad event does get launched, but the interface never updates with just the search results (it doesn't change).

Again, this code works just fine with the iPhone emulator, but doesn't with the Android.

Any ideas? Thanks!

— asked September 17th 2010 by Mike Shanafelt
  • android
  • mobile
  • tableview

2 Answers

  • I have been able to manually add and remove individual table rows. I haven't yet tried a total re-draw like you're doing.

    You don't have a tableview.setData(data) statement in your handler. Don't you need one? If that doesn't work, my guess is that you'll have to individually delete and create table rows.

    — answered September 17th 2010 by Tim Poulsen
  • Upon further testing, I'm pretty sure my problem has to do with the HTTPClient object, and not the TableView. I'm closing this question - the link to the new issue is at:


    Thanks for the reply, Tim. I'll look into that solution once I get the HTTPClient working.

    — answered September 17th 2010 by Mike Shanafelt
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.