ricardoalcocer / actionbarextras

Titanium Android Native Module that exposes ActionBar features not exposed by the Titanium SDK
MIT License
148 stars 60 forks source link

Tab group does not work with dropdown #41

Closed dplunkett3 closed 10 years ago

dplunkett3 commented 10 years ago

Adding a dropdown to a tab group causes the tabs to disappear.

Test case:

var abx = require('com.alcoapps.actionbarextras');
var opts = {dropdown: false};

var win1 = Ti.UI.createWindow();
var win2 = Ti.UI.createWindow();
var tabGroup = Ti.UI.createTabGroup({
    tabs: [Ti.UI.createTab({window: win1, title: 'Tab 1'}), Ti.UI.createTab({window: win2, title: 'Tab 2'})]
});

var dropdown
var btn_dropdown = Ti.UI.createButton({ title: 'Dropdown' });
btn_dropdown.addEventListener('click', function(){
    opts.dropdown = !opts.dropdown;

    if (opts.dropdown){
        dropdown = abx.createDropdown({
            titles: ["First", "Second", "Third"]
        });

        dropdown.addEventListener('change', function(e){
            Ti.API.info("dropdown changed to: " + e.index);
        });
    }else{
        dropdown.remove();
    }

});
win1.add(btn_dropdown);

tabGroup.open();

Note: I also tried creating the dropdown in the tab group's open event listener and in activity.onCreateOptionsMenu with the same result. It occurs on device with Android 4.4.2 and Genymotion emulator running 4.2.2, built with Ti SDK 3.4.0.GA.

manumaticx commented 10 years ago

Hi @dplunkett3

This is not a bug because the dropdown navigation actually replaces the tab navigation. The dropdown proxy changes the ActionBar NavigationMode to NAVIGATION_MODE_LIST following the official guide: Adding Drop-down Navigation

So, in the end, it's simply impossible to use drop-down and tabs at the same time.

As described here: Is it possible to use dropdown AND tabs as navigation in the action bar? it is not possible but a workaround that I would also recommend you is replacing the TabGroup with a ViewPager, e.g. this one: https://github.com/dreamlearn/viewpager

Hope this answers your question.

dplunkett3 commented 10 years ago

Thanks, I'll take a look at the ViewPager.