Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15496] Android TabGroup's actionBar actionViews don't expand

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2018-10-05T14:54:45.000+0000
Affected Version/sRelease 3.1.3
Fix Version/sn/a
ComponentsAndroid
LabelsSupportTeam
ReporterOlmo Kramer
AssigneeYordan Banev
Created2013-10-15T15:27:05.000+0000
Updated2018-10-05T14:54:45.000+0000

Description

Problem Description

When adding a menuItem to the actionBar with an actionView and
showAsAction : Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW | Ti.Android.SHOW_AS_ACTION_ALWAYS
to a TabGroup, the item never expands to show the actionView. This is with a TabGroup, and nothing happens when i click the 'search' icon.

Test Case

var win = Ti.UI.createTabGroup({
    backgroundColor: 'blue',
    fullscreen: false
});
var tab = Ti.UI.createTab({title: "test"});
var tabWin = Ti.UI.createWindow({title: "testWin"});
tab.window = tabWin;
win.add(tab);

var search;
var searchAsChild = false;

if (Ti.Platform.name == 'android' && Ti.Platform.Android.API_LEVEL > 11) {
    // Use action bar search view
    search = Ti.UI.Android.createSearchView({
        hintText: "Table Search"
    });

	win.addEventListener("open", function(e) {
    win.getActivity().onCreateOptionsMenu = function(e) {
        var menu = e.menu;
        var menuItem = menu.add({
            title: 'Table Search',
            actionView : search,
            icon: (Ti.Android.R.drawable.ic_menu_search ? Ti.Android.R.drawable.ic_menu_search : "my_search.png"),
            showAsAction: Ti.Android.SHOW_AS_ACTION_IF_ROOM | Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
        });
    };
	});
}
else {
    // Use search bar
    search = Ti.UI.createSearchBar({
        hintText: "Table Search"
    });
    searchAsChild = true;
}

var data = [];
data.push(Ti.UI.createTableViewRow({title:'Apple'}));
data.push(Ti.UI.createTableViewRow({title:'Banana'}));
data.push(Ti.UI.createTableViewRow({title:'Orange'}));
data.push(Ti.UI.createTableViewRow({title:'Raspberry'}));

var tableview = Titanium.UI.createTableView({
    data:data,
    search:search,
    searchAsChild:searchAsChild
});

win.add(tableview);
win.open();

Extra info

However, when i try it with a Window instead of a TabGroup, it does work: (note: this is identical to previous case except for changing the tabgroup to a window)
var win = Ti.UI.createWindow({
    backgroundColor: 'blue',
    fullscreen: false
});
//var tab = Ti.UI.createTab({title: "test"});
//var tabWin = Ti.UI.createWindow({title: "testWin"});
//tab.window = tabWin;
//win.add(tab);

var search;
var searchAsChild = false;

if (Ti.Platform.name == 'android' && Ti.Platform.Android.API_LEVEL > 11) {
    // Use action bar search view
    search = Ti.UI.Android.createSearchView({
        hintText: "Table Search"
    });

	win.addEventListener("open", function(e) {
    win.getActivity().onCreateOptionsMenu = function(e) {
        var menu = e.menu;
        var menuItem = menu.add({
            title: 'Table Search',
            actionView : search,
            icon: (Ti.Android.R.drawable.ic_menu_search ? Ti.Android.R.drawable.ic_menu_search : "my_search.png"),
            showAsAction: Ti.Android.SHOW_AS_ACTION_IF_ROOM | Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
        });
    };
	});
}
else {
    // Use search bar
    search = Ti.UI.createSearchBar({
        hintText: "Table Search"
    });
    searchAsChild = true;
}

var data = [];
data.push(Ti.UI.createTableViewRow({title:'Apple'}));
data.push(Ti.UI.createTableViewRow({title:'Banana'}));
data.push(Ti.UI.createTableViewRow({title:'Orange'}));
data.push(Ti.UI.createTableViewRow({title:'Raspberry'}));

var tableview = Titanium.UI.createTableView({
    data:data,
    search:search,
    searchAsChild:searchAsChild
});

win.add(tableview);
win.open();

Comments

  1. René Wilby 2014-01-22

    I can confirm that in TiAlloy 1.3 and SDK 3.2.0.GA on Android 4.1.2 and Android 4.3.
  2. Rainer Schleevoigt 2014-08-21

    +1 I have the same issue in my project
  3. jithinpv 2014-09-12

    Issue reproduces Titanium SDK version 3.4.0 master, 3.1.3.GA Titanium Studio, build: 3.3.0.201407100905 Titanium Command-Line Interface CLI version 3.3.0, Android device : Motorola Moto G, Android version : 4.4.4 Note : in SDK 3.4.0 master search button is displayed.
  4. Yordan Banev 2018-10-05

    Tested with 7.0.0.GA the issue can't be reproduced. Closing as such.

JSON Source