Titanium Community Questions & Answer Archive

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

Android TabGroups

Is it possible to create a tabGroup that is static across all the screens in an android application? I am currently using Titanium Developer 1.2.1 and sdk 1.1.2.

What I want to do is have one master tabGroup (similar to iPhone) that lives on every screen. Does anyone have any advice on how to accomplish this?

Thanks in advance,
-Spencer

— asked April 8th 2010 by Spencer Smith
  • 1.1.2
  • android
  • tabgroup
0 Comments

5 Answers

  • I haven't exactly dove into the scripting using Appcelerator yet, but I've looked through the code provided for Snapost, and it does something similar.

    var headerView = Titanium.UI.createView({ ... top:0, height:60, width:320 });

    var viewContainer = Titanium.UI.createView({ top:60, width:320, height:420 });

    var app = Ti.UI.createWindow({...}); app.add(headerView); app.add(viewContainer);

    All the other views (chooser, config, result, confirm) were all added views to the viewContainer view, and their display was toggled.

    — answered April 9th 2010 by Ben Babics
    permalink
    0 Comments
  • Ben,
    I have seen that and I know there are some ways around this by not using the TabGroups, however I would like to control my screen stacks using one master TabGroup (similar to what you can do with iPhone). Ideally I will have three different tab groups that will allow three different user flows. Thanks for the advice, I will have to check out SnapShot to see if it is indeed working the way I need it to!

    -Spencer

    — answered April 9th 2010 by Spencer Smith
    permalink
    0 Comments
  • Hi Spencer,

    A lot of this is outlined in a newly created project. See below:

    1. Create the tabgroup
      var tabGroup = Titanium.UI.createTabGroup();

    2. Create windows (the same amount as tabs, i believe)
      var win1 = Titanium.UI.createWindow({...}); var win2 = Titanium.UI.createWindow({...});

    3. Create tabs (the same amout as windows, i believe)
      `var tab1 = Titanium.UI.createTab({

      window:win1
      });

    var tab2 = Titanium.UI.createTab({

    window:win2
    });`

    1. Add Tabs to tabGroup
      tabGroup.addTab(tab1); tabGroup.addTab(tab2);

    2. Open tabGroup
      tabGroup.open();

    Hopefully this helps. Cheers!

    — answered April 9th 2010 by Ben Babics
    permalink
    0 Comments
  • Ben,

    This is the method I use for creating tabs in my app.js file. From there I am kicking off a window in each of the three tabs that represents each of my display stacks. The issue is that when you use the following code:

    Ti.UI.currentTab.open(someWindow,{animated:true});

    It will create a new window that does not contain the tabGroup (i.e. the tab group will only live on one screen at a time). When it is compiled on iPhone the tabGroups will live throughout the applications which I believe is native support to iPhone.

    I have been able to somewhat get around this by using:

    someWindow.open();

    From the current window instead of:

    Ti.UI.currentTab.open(someWindow,{animated:true});

    However that does not always work as I want, and when I press the back button on the Android phones it will exit the app instead of pushing back to the previous window.

    Thanks again,
    -Spencer

    — answered April 9th 2010 by Spencer Smith
    permalink
    0 Comments
  • Please be aware of the ticket I mentioned in this post when dealing with tabgroups.

    — answered November 10th 2010 by Paul Dowsett
    permalink
    0 Comments
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.