Activity Indicator on android

You must Login before you can answer or comment on any questions.

Hi,

Could we add activity indicator to a view.

i have an android app with only one Window which contains views...each view display activityIndicator while loading data...

and activity indicator does'nt be displayed...

here is the code :

var winAccueil = Ti.UI.createView({
        backgroundColor: '#fff'
    });
 
 
    var actInd = util.createActivityIndicator();
    winAccueil.add(actInd);
    actInd.show();
 
    function loadArticles(){
    ....
    actInd.hide();
}
it doesn't work.

thanks for help.

2 Answers

Accepted Answer

Activity indicators are different on Android.

On Android they are not views that you add to other views, but in fact windows

Try NOT adding it to any view, just showing it

if(Ti.App.platformName == 'iphone'){
    winAccueil.add(actInd);
}

It looks like you create a view winAccueil but nowhere do you add it to the window. You can't display an indicator inside the view if the view isn't added to the window.

— answered 10 months ago by Anthony Decena
answer permalink
1 Comment
  • i add it to the window winTabs :

    exports.createTabs = function(){
     
        var winTabs = Ti.UI.createWindow({
            backgroundColor: '#fff',
            navBarHidden: true,
            exitOnClose: true
        });
     
        var viewAccueil = require('ui/winAccueil').createWindow();
        var viewChoixRubrique = require('ui/winChoixRubrique').createWindow();
        var container = Ti.UI.createView({bottom:50});
     
        winTabs.addEventListener('open', function(e){
            viewChoixRubrique.visible = false;
            viewAccueil.visible = true;
     
            container.add(viewAccueil);
            container.add(viewChoixRubrique);
     
        });
     
        //tabs 
        var tabGroup = Ti.UI.createView({ layout: 'horizontal', bottom: 0, height: 50, backgroundImage: Ti.Filesystem.resourcesDirectory + 'images/bottom_bar.png' });
     
        var tab1 = Titanium.UI.createImageView({backgroundImage: Ti.Filesystem.resourcesDirectory + 'images/accueil_on_android.png', width: '20%', height: 50});
     
        tab1.addEventListener('click', function(e){
            viewAccueil.visible = true;
            viewChoixRubrique.visible = false;
     
            tab1.backgroundImage = Ti.Filesystem.resourcesDirectory + 'images/accueil_on_android.png';
            tab2.backgroundImage = Ti.Filesystem.resourcesDirectory + 'images/rubriques_off_android.png';
     
        });
     
        var tab2 = Titanium.UI.createImageView({backgroundImage: Ti.Filesystem.resourcesDirectory + 'images/rubriques_off_android.png', width: '20%', height: 50});
     
        tab2.addEventListener('click', function(e){
            viewAccueil.visible = false;
            viewChoixRubrique.visible = true;
     
            tab1.backgroundImage = Ti.Filesystem.resourcesDirectory + 'images/accueil_off_android.png';
            tab2.backgroundImage = Ti.Filesystem.resourcesDirectory + 'images/rubriques_on_android.png';
        });
     
        tabGroup.add(tab2);
        tabGroup.add(tab1);
     
        winTabs.add(container);
        winTabs.add(tabGroup);
     
        return winTabs;
    };

    — commented 10 months ago by Djamel ZAHAL

Your Answer

Think you can help? Login to answer this question!