Titanium Community Questions & Answer Archive

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

giving to the community: custom tabgroup class working on android and iphone

this is a custom tabgroup class done in js by using standard ti-mobile view-classes that will look the same on android and iphone. i used this for an app called "A1 BVB Grand Slam" that was released for Android some days ago, and will be in the Apple appStore tomorrow if things go well

the code should be self-explanary!

you can get it on my public dropbox:

screenshot android: http://dl.dropbox.com/u/143939/tabs_xcompat_android.png
screenshot iphone: http://dl.dropbox.com/u/143939/tabs_xcompat_iphone.png

also thanx to bill dawson from appcelerator who helped me getting it working on both platforms!

— asked July 27th 2010 by Christian Sigl
  • android
  • crosscompatible
  • iphone
  • tabgroup
  • I just wanted to say thank you for sharing this with the community.

    I need tabs to do a few things that the default tabs can not, so this will really help.

    The fact that it's cross platform is very nice, and I can tell took you a long time to setup, so thank you again!

    Peter Janett

    — commented September 3rd 2010 by Peter janett
  • Thanks for sharing Christian! For a newb like me this is a great way to learn.

    — commented November 22nd 2010 by Kevin
  • Does work now, comes up with an error in Android 2.2 and 2.3.

    — commented December 22nd 2010 by James Adams
  • Does not!

    — commented December 22nd 2010 by James Adams
  • Awesome stuff Chris, thanks for sharing with the community.

    — commented January 4th 2011 by Antonio Silveira
  • This is a excellent code and help me very much. Appreciate your contribution, thanks.

    — commented March 8th 2011 by andy chiang
  • This code is working perfectly, but one small job I would like to do more is if we want to put a text in each tab, is it possible? I try to put title tag in class but it doesn't work…

    — commented March 8th 2011 by andy chiang
  • Thanks. 37.2 Mb ? Is it only the library or the full code of your application ?

    — commented March 17th 2011 by Guillaume LA
  • Awesome work! Works great for me.

    — commented March 28th 2011 by Ryan Lowe
  • Hi Chris, I used your work but I every time I press the android back button(the phone button) the app quits. I guess that's why you add back button inside the app. Is there anyway to use the phone back button???? Thank you!

    — commented August 11th 2011 by Sihang H
  • I just want to thank you for sharing your work with us.

    — commented July 23rd 2012 by Marco Seguri
  • Hi Christian, I appreciate your very contributed codes.

    Seems this works great on both iOS and Android with Titanium SDK 2.1.0GA. (XCode 4.2 OSX 10.6.8)

    — commented August 6th 2012 by Mitsutaka Naito
  • Great! Thanks a lot for sharing! :D

    — commented October 16th 2012 by Gianluca Di Matteo
  • Great Sharing, Thanks.

    — commented December 31st 2012 by Ashish Nigam
  • it doesn't work on Andrid on

    — commented March 29th 2013 by Armindo Da Silva

13 Answers

  • Hey Christian,

    The custom tab group program, you made, is not working in Titanium 1.5.1. The error message says "IllegalArgumentException: Expected 2 arguments for log, got 1(app://app.js#77). Do you know what the issue could be?

    — answered January 3rd 2011 by Michael Warren
    • You just have to change the 'log' to 'info' and check the messages which appear on titanium.

      — commented January 7th 2011 by Zheng Da Clinton Goh
    • Here is the details of the error I get in the log window with 'info' chosen. [WARN] (skipping hidden file '/Users/flashdev/appcelerator/tabs_xcompat/build/android/bin/assets/.DS_Store')
      [WARN] (skipping hidden file '/Users/flashdev/appcelerator/tabs_xcompat/build/android/bin/assets/Resources/.DS_Store')
      [WARN] (skipping hidden file '/Users/flashdev/appcelerator/tabs_xcompat/build/android/bin/assets/Resources/images/480x854/.DS_Store')

      How can I fix this???

      — commented January 12th 2011 by Michael Warren
    • Running:
      Titanium Developer 1.2.2
      Titanium Mobile SDK 1.5.1
      Android 2.3.1 SDK

      I get the same error message when the app tries to run in the emulator.

      BTW the .DS_Store error is unrelated, just remove those files as they are not needed.

      — commented January 27th 2011 by Mutasim Karim
  • Hi Christian, thanks for your contribution. I noticed that in app.js, you did this:

    // And:

    Any reason for doing this?

    I was playing around with your class and customised it further; it seems to work quite well, but when I try to display a scrollView, it displays the scroll view two times, one on top of the other. The first is scrollable by mouseclick / finger drag, and the other is scrollable by mousewheel / finger swipe on Android's navigator.

    I'll probably have to figure a solution out by myself. Just giving a heads up for those of you who're using this custom class.

    — answered January 7th 2011 by Zheng Da Clinton Goh
    1 Comment
    • Hi Christian, I read your post on the window.close(); problem. I was reading through all the replies, but didn't find anything conclusive. So does window.close(); free up memory? On my app I'm using a custom table view which utilises quite a number of pictures, graphics etc. It seems (at least to me), that window.close(); DOES NOT free up memory. Did the app developers help you solve this issue?

      — commented January 8th 2011 by Zheng Da Clinton Goh
  • Here is the details of the error I get in the log window with 'info' chosen. [WARN] (skipping hidden file '/Users/flashdev/appcelerator/tabs_xcompat/build/android/bin/assets/.DS_Store') [WARN] (skipping hidden file '/Users/flashdev/appcelerator/tabs_xcompat/build/android/bin/assets/Resources/.DS_Store') [WARN] (skipping hidden file '/Users/flashdev/appcelerator/tabs_xcompat/build/android/bin/assets/Resources/images/480x854/.DS_Store')

    This is using version 1.5.1

    — answered January 12th 2011 by Michael Warren
    1 Comment
    • this is not really an error : remove hidden file (.DS_Store), and this will remove WARN log message

      — commented January 13th 2011 by Stephane Pelamourgues
  • First off thanks for sharing. This is exactly what I was looking for. However, I'm having an issue. The window displayed as my initial tab doesn't seem to respond to the events it registers. Button clicks don't do anything and the window seems to never close. If I take the same tab and make it the "2nd" tab things seem better.

    Any ideas?

    — answered February 5th 2011 by Frank A
  • Thanks for sharing!

    It works in Titanium 1.5.1. You just need to comment out the logging lines in each file, or fix the syntax errors on those lines. I just commented them out.

    It just does not work in landscape mode. Tilt the phone with Ctrl + F11 and you'll find the navigation does not fix nicely. But it is a good example to get me started and I appreciate your post.

    I am going to download "A1 BVB Grand Slam" to figure out how you sized the navigation on tilt.

    — answered February 21st 2011 by Matt Weber
    1 Comment
    • the app wasn't designed for landscape mode, so the tabview didn't come with this feature

      — commented July 20th 2011 by Christian Sigl
  • sorry, for not having answered all those questions, i simply didn't get any notification after my latest comment 8 months ago

    i'm now in the situation of having to update the app i used the tab-code for, and found that in the latest ti-mobile releases there is a nasty crash in android when switching tabs that do include a webview. so if anyone run over this issue while using my code, and found a fix, i'd be more than happy hearing from you ;-)

    — answered July 20th 2011 by Christian Sigl
  • Sorry to rake up an old post, how do I get this to work?

    — answered December 27th 2012 by Steve Davies
  • How do I get this to work?

    — answered December 27th 2012 by Steve Davies
  • Christian, I am using your example for my application.
    this is on iphone android is working good.
    I am getting an issue. I have custom navigation with three tabs.
    My second tab have button after clicking it, it will open new window,

    At the time Iam in new window if i click top navigation my new window from button click is not closing.

    how can I close that sub window?


    — answered May 17th 2011 by Sachit Nimmagadda
  • Christian, thank you so much for sharing with us,

    Android 2.2-api works fantastic
    Iphone iOS 4.0.2, TI sdk, tab3 crash, also I will paste the logs:


    do you thing you can put your excelent work compatible with spec above?

    Keep your good work!

    — answered October 25th 2010 by Nuno Costa
  • Hi Christian,

    i need some help if possible.

    Your custom tabs work perfectly, but if i switch from tab to tab, the previous content is not saved, therefore if i am in some child windows, i and switch tabs, when i go back, its the window recreated from scratch.

    Is there any way of saving the pages when you switch.

    Thanks alot!


    — answered December 17th 2010 by Thomas Shurrock
    1 Comment
    • sorry, i didn't need such feature for my app when i coded the tab-groups, however you might have sucess in saving your data as a json-encoded property-string before closing a tab and recalling it after opening it/drawing the elements again

      — commented December 17th 2010 by Christian Sigl
  • I run your code perfectly in Android 2.2, but when I run your code in iPhone 4.2, I got following error…

    [ERROR] Error: Traceback (most recent call last):
    File "/Library/Application Support/Titanium/mobilesdk/osx/1.6.0/iphone/builder.py", line 1003, in main
    execute_xcode("iphonesimulator%s" % link_version,["GCC_PREPROCESSOR_DEFINITIONS=LOGID__=%s DEPLOYTYPE=development TI_DEVELOPMENT=1 DEBUG=1 TI_VERSION=%s" % (log_id,sdk_version)],False)
    File "/Library/Application Support/Titanium/mobilesdk/osx/1.6.0/iphone/builder.py", line 924, in execute_xcode
    output = run.run(args,False,False,o)
    File "/Library/Application Support/Titanium/mobilesdk/osx/1.6.0/iphone/run.py", line 39, in run

    SystemExit: 1

    I found the two file "MainWindow.xib" and "MainWindow_ipad.xib" in iphone directory, is it a reason cause this issue?

    Any idea?

    — answered March 8th 2011 by andy chiang
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.