TabGroup in window

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

I have made var createtabgroup. But i want to make with adding button and label in top of tabgroup. And so, i make var createwindow. When i add tabgruop in window, it can not running in application. What make it wrong? Any better solution? Thank you. Hope get your best solution.

I use android 2.2 and Win 7 x32

7 Answers

You don't add tabgroups to a window, you add windows to a tabgroup. I'd suggest skimming the TabGroup Docs once and then possibly creating a default project to see an example of how the TabGroup works.

TabGroup is the most Parent Element.and window is its child.So,I dnt think,it is possible to add native tabgroup to a window.if u want the same,i think you can make your own customized tab group and then you can add that on window.

— answered 9 months ago by pankaj Goyal
answer permalink
3 Comments
  • ok, if it makes it simple, how can i add button like "home" or "Next" on the top tabgroup? Thanks Before. :)

    — commented 9 months ago by yosua hendrik

  • I meant that you need to create your own customized group.like we create a button bar and wrote logic on clicking the buttons.now in case of tabgroup,on clicking your customized button,you can add your windows.I guess you understand what i am trying to say,if not then let me know.

    — commented 9 months ago by pankaj Goyal

  • I have tried that. But it can't apply. Because var createbutton is inputed in var createwindow, and var createwindow is inputed in tabgroup. How can make it better? Thanks before :)

    — commented 9 months ago by yosua hendrik

I have not been able to answer to my problem. For the simple, what i should do, if i want to show button "home" and "next" on the top of many tab within there is window in each tab? Big hope to help me well. :(

For each window that you attach to a tab, you can use the leftNavButton and rightNavButton to add buttons to the title bar for each. Assuming win1 below is attached to tab1 it would look something like this:

var homebtn = Ti.UI.createButton({
    title:'Home'
});
homebtn.addEventListener('click', function() {
    alert('You clicked the home button.')
});
win1.leftNavButton = homebtn;
 
var nextbtn = Ti.UI.createButton({
    title:'Next'
});
nextbtn.addEventListener('click', function() {
    alert('You clicked the next button.')
});
win1.rightNavButton = nextbtn;
Please keep in mind, that if you open a new window within a tabgroup like this:
tabGroup.currentTab.open(newWindow);
Then newWindow will automatically get a 'back' button as the left nav button, so you wouldn't want to override that functionality.

— answered 9 months ago by Anthony Decena
answer permalink
4 Comments
  • Thanks for your answer. But, i meant that i can't show button "Home" and "Next" on the top of many tab. For this case, i use var createTabGroup. and put button in var createWindow. and add var createWindow in var tabgroup. As reference, article of Titanium said, "On Android, the tab does not maintain a stack of windows. Calling open opens a new, heavyweight window, which by default covers the tab group entirely....".

    So, how can i show 'my button on the top of tabs' with your solution?. Big hope you fix my problem. Thanks :)

    — commented 9 months ago by yosua hendrik

  • Bah, Im sorry, at this point I completely forgot that you were using Windows and Android. If you want to add the buttons to the top of a heavyweight window, you'll just need to create a view and add the two buttons to it. If you create it as a commonjs module, then you can easily add it to any window that gets created. As said, it won't maintain a stack of windows, so you'd have to do that yourself if you plan on opening many windows, in which case a next button and a close button may be better suited.

    — commented 9 months ago by Anthony Decena

  • Anthony, it's not work. Because like previous comment, "You don't add tabgroups to a window, you add windows to a tabgroup.". Or, could you give the coding to fix it? Because i am struggling with this.. Big hope :)

    — commented 9 months ago by yosua hendrik

  • Show 1 more comment

I'm posting this as a completely different answer as to not confuse it with the conversation in the previous thread. Try this Navigation Controller, I think it might do everything that you are looking for. Import the entire test app from: https://github.com/xsaero00/Ti-Navigation-Controller

— answered 9 months ago by Anthony Decena
answer permalink
2 Comments
  • Ok, thanks, anthony. I'll try. :)

    — commented 9 months ago by yosua hendrik

  • Anthony, i have run your code. But, it's not about tabgroup. Ok, i want to make application like this url http://imageshack.us/photo/my-images/255/unnamedi.jpg/ . This picture is foursquare. So, foursquare has 3 tab. And on the top of tabs, there is a button. So, how can it be added on the top?? Could give me a code? For my code, i make like this

    // this sets the background color of the master UIView (when there are no windows/tab groups on it) Titanium.UI.setBackgroundColor('#800000');

    // create tab group

    var tabGroup = Titanium.UI.createTabGroup();

    var win1 = Titanium.UI.createWindow({
    title:'Original', url:'tab/original.js' });

    var tab1 = Titanium.UI.createTab({
    icon:'KS_nav_views.png', title:'Original', window:win1 });

    var win2 = Titanium.UI.createWindow({
    title:'Paket', url:'tab/paket.js' });

    var tab2 = Titanium.UI.createTab({
    icon:'KS_nav_ui.png', title:'Praktis', window:win2 });

    // add tabs

    tabGroup.addTab(tab1);
    tabGroup.addTab(tab2);

    // open tab group

    tabGroup.open();

    — commented 9 months ago by yosua hendrik

Anthony, i have run your code. But, it's not about tabgroup. Ok, i want to make application like this url http://imageshack.us/photo/my-images/255/unnamedi.jpg/ . This picture is foursquare. So, foursquare has 3 tab. And on the top of tabs, there is a button. So, how can it be added on the top?? Could give me a code? For my code, i make like this

// this sets the background color of the master UIView (when there are no windows/tab groups on it)

Titanium.UI.setBackgroundColor('#800000');

// create tab group

var tabGroup = Titanium.UI.createTabGroup();

var win1 = Titanium.UI.createWindow({ title:'Original', url:'tab/original.js' });

var tab1 = Titanium.UI.createTab({ icon:'KS_nav_views.png', title:'Original', window:win1 });

var win2 = Titanium.UI.createWindow({ title:'Paket', url:'tab/paket.js' });

var tab2 = Titanium.UI.createTab({ icon:'KS_nav_ui.png', title:'Praktis', window:win2 });

// add tabs

tabGroup.addTab(tab1); tabGroup.addTab(tab2);

// open tab group

tabGroup.open();

Ok, see, your code and the image should have been posted in the original question, we wouldn't be this deep if you would have posted them in the beginning, and we definitely would have had an answer by now. For your current code, you should think about switching to commonjs if you're going to be using a common element (like the one Im about to give you below) on all your windows. You can see how commonjs apps are structured by creating a new app using the tabbed application template.

I'm not going to write the code for you, but I'll give you the basic idea with some pseudo-code that you can use.

// Create a header view container that will encapsulate everything in the header
// This should fill the entire width of the device, and be only as high as the elements you put in it
var headerView = Ti.UI.createView();
 
// Create the image view for your logo. Position this all the way to the left and add it to the view
var logo = Ti.UI.createImageView();
headerView.add(logo);
 
// Create your home button, use an image as the bg. Position this all the way to the right and add it to the view.
var homeBtn = Ti.UI.createButton();
headerView.add(homeBtn);
 
// Do the same thing with the back btn. Position it next to the home btn and add it to the view.
var backBtn = Ti.UI.createButton();
headerView.add(backBtn);
 
// Add any extras that you need, event listeners, actions, etc. then return the headerView and add it to the window.
Now if you wrap all that in a commonjs module and then add it to every window that you need the bar on.

— answered 9 months ago by Anthony Decena
answer permalink
11 Comments
  • hehe, i should tell it first. And thanks for your pseudo code. Ok, i hope you patient with my problem. hehe. And the problem i have is, tabgroup can't be joined inside window and vice versa. So that, i can't adding button on the top of groupTab, like picture which i have showed to you. because i add button in var createWindow and because in article Titanium, tabgroup is window and vice versa, so that, in other words, windows is impossible inside window.

    //

    this problem is about tabgroup and button. How can you fix it with your way???

    I have searched many answers, but not right solution. And I am still an amateur with titanium. Thanks. Big hope :))

    — commented 9 months ago by yosua hendrik

  • In the image that you posted, the app uses a custom interface. There is no tab group in the app. There is a header view, then a custom navigation component that looks and works a bit like a tab group. If you want to duplicate this, you'll have to create a completely custom component to do so.

    — commented 9 months ago by Anthony Decena

  • Hmm, so, 3 tabs in foursquare is just custom component which declare that the tab is not real tab, but that is button which has window. OK, may be i try first. Thanks for your help. :)

    — commented 9 months ago by yosua hendrik

  • Show 8 more comments

Your Answer

Think you can help? Login to answer this question!