TableView Navigation in Android

You must Login before you can answer or comment on any questions.

I'm having some trouble with TableView navigation on the Android version of my app. The same code works perfectly fine on the iPhone but when I try to run it on the Android, nothing actually happens when I click on a row.

What can I do to fix this?

Here is the eventlistener code:

professionsTable.addEventListener('click', function(e)
{
    alert(JSON.stringify(e.row));
 
    if (e.row.path)
    {
         var win = Ti.UI.createWindow({
                url: e.row.path,
                title: e.row.title
        });
 
        var profession = e.row.title;
        win.profession = profession;
 
        //On Android, tabs don't maintain their own stack of windows
        if (Ti.Platform.osname === 'android') {
            win.open();
        }
        else {
            Ti.UI.currentTab.open(win);
        }
    }
});
And the row creation code:
tableviewArray.push( {title: foo, class: "profession", hasChild: true, path: 'profession_details.js'} );
Any help would be appreciated! Thanks!

1 Answer

Accepted Answer

Two problems:

  • if you're using TabGroup, you should always open the new window via the active tab (it's not just an iOS thing, it's an android thing)
  • Ti.UI.currentTab doesn't work

I think you're probably stumbling across old documentation that can be very misleading. You must always use the active tab, and it's up to you to keep track of the TabGroup in a variable somewhere.

See a previous post of mine and see if that helps out.

— answered 11 months ago by Jason Priebe
answer permalink
5 Comments
  • I'm trying to implement your TGWM into my app, but I keep getting an error when I launch my app. It says that tgwm.createTabGroup() is not a valid function...

    var TGWM = require ('/TGWM');
    var tgwm = new TGWM ();
    var tabGroup = tgwm.createTabGroup ();

    — commented 10 months ago by Dro Sarhadian

  • Sorry -- my sample code was bad. Do this instead:

    var TGWM = require ('/TGWM');
    var tabGroup = TGWM.createTabGroup ();

    — commented 10 months ago by Jason Priebe

  • That worked, but now when I try to open a new window, I have the same problem as my original post..

    professionsTable.addEventListener('click', function(e)
    {   
        if (e.row.path)
        {
             var win = Ti.UI.createWindow({
                    url: e.row.path,
                    title: e.row.title
            });
     
            var profession = e.row.title;
            win.profession = profession;
     
            var TGWM = require('/TGWM');
     
            //Open the new window
            TGWM.openWindow(win);
        }
    });

    — commented 10 months ago by Dro Sarhadian

  • Show 2 more comments

Your Answer

Think you can help? Login to answer this question!