Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

ActionBar can disappear if not coded 'rightly'

$
0
0

I have this test code:

// index.xml
<Alloy>
    <Window class="container" fullscreen="true" onOpen="OnOpen" exitOnClose="true">
        <Menu id="menu" platform="android">
            <MenuItem id="menuItem" title="Sync Now" showAsAction="Ti.Android.SHOW_AS_ACTION_ALWAYS" />
            <MenuItem id="menuItem" title="Settings" showAsAction="Ti.Android.SHOW_AS_ACTION_NEVER" />
            <MenuItem id="menuItem" title="About" showAsAction="Ti.Android.SHOW_AS_ACTION_NEVER" />
            <MenuItem onClick="OnExit" id="menuItem" title="Exit" showAsAction="Ti.Android.SHOW_AS_ACTION_NEVER" />
        </Menu>
        <View layout="vertical">
            <Label id="label" onClick="doClick">Hello, World</Label>
            <TableView id="table">
                <TableViewSection id="sectionFruit" headerTitle="Contact Info">
                    <TableViewRow>
                        <Label text="Contacts" left="10"/>
                        <Label id="lblContactCount" text="NA" right="10"/>
                    </TableViewRow>
                    <TableViewRow title="Bananas"/>
                </TableViewSection>
            </TableView>
        </View> 
    </Window>
</Alloy>
Controller:
// index.js
function OnOpen() {
    $.index.addEventListener('android:back', function(){
        OnExit();
    });
 
    setTimeout(function() {
        $.lblContactCount.text = Ti.Contacts.getAllPeople().length;
    },1000);
 
    $.index.activity.actionBar.title = 'My App';    
}
The latest thing I did on the code was to update the text in lblContactCount. This seems to cause the ActionBar to disappear when the app loads up. The trick I did was to put the lblContactCount on a delayed action (via setTimeout).

The code above works. But I'm not sure why it works. Appreciate if those in the know can share their thoughts on this. My experience with ActionBar to date has been rather flaky.

Thanks.


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>