Question

I'm trying to create a menu on index.xml in android titanium:

    <Window  class="container" title="My Books">
        <TableView dataCollection="books" id="bookTable">
            <TableViewRow title="{title}" author="{author}" onClick="showBook">  </TableViewRow>
        </TableView>
        <Menu id="menu" platform="android">
            <!-- Cannot specify node text.  Use attributes only. -->
            <MenuItem id="addBook"
                title="Add book"
                onClick="addBook"
                showAsAction="Ti.Android.SHOW_AS_ACTION_IF_ROOM" />
        </Menu>
    </Window>

</Alloy>

but then after running the application, my console give me this error

[WARN][TiAPI   (  391)]  You attempted to attach an Android Menu to a lightweight Window
[WARN][TiAPI   (  391)]  or other UI component which does not have an Android activity.
[WARN][TiAPI   (  391)]  Android Menus can only be opened on TabGroups and heavyweight Windows.

so I tried to put a

$.index.open({modal:true});

to make the menu work. But the problem is when I use the backbutton on my phones hardware it goes back to splashscreen and still have to click the back button.

Is there a fix to make the menu work on lightweight windows? or is there a fix on closing the app by clicking the back button thought its a heavyweight window?.

Was it helpful?

Solution

To exit the screen when the back button is pressed on the main window, add exitOnClose='true' to the <Window> element:

<Window class="container" exitOnClose="true">

FYI, this behavior is a regression from 3.1.x (https://jira.appcelerator.org/browse/TIMOB-16330).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top