KaySee
KaySee

Reputation: 423

How Removing window from a tab in titanium?

I am using titanium appecelerator to build an app in both ios and android.

I use the following code to create a tab group and add a tab to it.

  var localTabGroup = Ti.UI.createTabGroup();

  var planTab = Ti.UI.createTab({
            title : NYC.Common.StringConstant.TAB_TITLE_PLAN,
            icon : NYC.Common.ResourcePathConstant.IMG_TAB_PLAN,
            window : planTabWin

        });

   localTabGroup.open();

And call the following function to create a window and add it to the tab

 addWindowToTabGroup : function(window) {

        tabGroup.activeTab.open(window, {
            animated : true
        });
    },

Now, I often have to remove window from the stack of the tab ( eg: on android back button or ios navigation bar back)

Till now, I use window.close() to remove the window from the stack . But, it always shows warnings like.

[ERROR][TiBaseActivity(  378)] (main) [3320,4640528] Layout cleanup.

[WARN][InputManagerService(   62)] Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@406e4258

I was just wondering if I am following the correct approach? Or is there a better way to remove a window from the tab?

Thanks.

Upvotes: 0

Views: 995

Answers (1)

Josiah Hester
Josiah Hester

Reputation: 6095

Tabs behave a lot differently on iOS and Android, 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.This is very different from iOS, but it is for Android applications. Users always use the Back button to close the window and return to the tab group.

This may be happening because you are trying to remove the window even though natively Android already removes it. Check out the Android Implementation Notes of the docs here

To completely eliminate this problem, I would just open up a modal window without using the TabGroup, this would be more cross platform:

addWindowToTabGroup : function(window) {

    window.open({
        modal : true,
        animated : true
    });
}

This will open a modal window which behaves the same on both platforms, and can be handled easily by the native back button functionality.

Upvotes: 1

Related Questions