Blink label (text)

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

Hello, does anyone have a problem with blinkiking text?

I dont know why but my label keeps blinkin (showing and disappearing in 0.5 seconds or so...) its almost impossible to read the label

Thanks!

9 Answers

Are you running any setInterval javascript that might be firing every 0.5seconds ?

No, my friend, not at all.

Here is the code:

Ti.include('/network.js');
 
 
var currentWindow = Ti.UI.currentWindow;
 
currentWindow.orientationModes = [Ti.UI.PORTRAIT];
 
var tipo = 10;
 
 
var sql = currentWindow.noticia.ID;
 
 
var network = new Network(sql, tipo);
 
network.loadNetwork(function(data) {
 
var dados = data;
 
 
var view = Ti.UI.createScrollView({
 
layout : 'vertical',
 
contentHeight : 'auto',
 
width : '100%',
 
left : '5dp'
 
});
 
 
var Titulo = Ti.UI.createLabel({
 
text : (currentWindow.noticia.nome),
 
color : 'black',
 
height : 'auto',
 
top : '5dp',
 
width : '100%',
 
textAlign : 'left',
 
font : {
 
fontWeight : 'bold',
 
fontSize : '22dp'
 
}
 
});
 
var Texto = Ti.UI.createLabel({
 
text : (' ' + dados[0]['texto']),
 
color : 'black',
 
height : 'auto',
 
top : '15dp',
 
width : '100%',
 
textAlign : 'left',
 
font : {
 
fontSize : '18dp'
 
}
 
});
 
 
view.add(Titulo);
 
view.add(Texto);
 
currentWindow.add(view);
 
 
});
Any suggestion?

PS: I didnt try it on the iphone, I am using the Iphone Simulator.

Thanks!

— answered 1 year ago by Lucas Henrique Pinto
answer permalink
1 Comment
  • Without seeing what is inside the network.js file I cant really tell. However if your function loadNetwork is returning data more than once then the flickering you are seeing maybe because you are creating the labels again and again in the same place

    — commented 1 year ago by Nick Milner

I think there is something wrong with the TI.UI.createScrollView

if I use Ti.UI.createScrollableView, the text and title dont blink, but I am unable to scroll the text...

any tips?

PS: Sorry for my own replies, I was just trying to add more information so ppl could use the info to figure a way out

Thanks!

Hello Lucas,

I did a simplification of this:

var currentWindow = Ti.UI.createWindow(
    {backgroundColor:'white',}
);
 
currentWindow.orientationModes = [Ti.UI.PORTRAIT];
 
function loadNetwork() {
 
    var view = Ti.UI.createScrollView({
 
        layout : 'vertical',
 
        contentHeight : 'auto',
 
        width : '100%',
 
        left : '5dp'
 
    });
 
    var Titulo = Ti.UI.createLabel({
 
        text : 'Otro Texto',
 
        color : 'black',
 
        height : 'auto',
 
        top : '5dp',
 
        width : '100%',
 
        textAlign : 'left',
 
        font : {
 
            fontWeight : 'bold',
 
            fontSize : '22dp'
 
        }
 
    });
 
    var Texto = Ti.UI.createLabel({
 
        text : 'Texto ',
 
        color : 'black',
 
        height : 'auto',
 
        top : '15dp',
 
        width : '100%',
 
        textAlign : 'left',
 
        font : {
 
            fontSize : '18dp'
 
        }
 
    });
 
    view.add(Titulo);
 
    view.add(Texto);
 
    currentWindow.add(view);
 
}
 
loadNetwork();
currentWindow.open();
and can't reproduce the blinking. I tested with Ti MobileSDK 1.8.1 and iOS 5.0. Can you please try the code and let me know what do you see?

Best,

Mauro

Hello Mauro! Thanks for your help.

I tried your code and the blink didnt appear... it was normal =/

I tried already taking away the backgroundimage (of my window) and setting just a backgroundcolor but it still keep bliking... the only way it stops blinking is when I change scrollView for scrollableView, but this way the label doesnt scroll at all.

Any further tips?

Thanks again for your time!

I am also showing my network.js, if someone could check if this is causing the problem, I would be REALLY GRATEFUL!

But I don't think the problem is in network.js, or else i wouldn't fix when I change createScrollView for createScrollableView, I guess...

but anyway, here is the code!

Thanks everyone for your help

function Network(dados, tipo) {
    var url = "http://www.oba.com.br/webservice/json.php";
 
    var carregando = Ti.UI.createLabel({
        text : "Carregando...",
        top : '30%',
        color : "black",
        height : '10%',
        width : '100%',
        textAlign : 'left',
        font : {
            fontWeight : 'bold',
            fontSize : '18dp'
        }
    });
 
    var progressBar = Ti.UI.createProgressBar({
        min : 0,
        max : 1,
        value : 0,
        width : '98%',
        height : '100%',
        color : "#FFF",
        shadowColor : "#64696e",
        shadowOffset : {
            x : 0,
            y : -1
        },
        font : {
            fontSize : 14,
            fontColor : "black",
            fontWeight : "bold"
        }
    });
    currentWindow.add(carregando);
    currentWindow.add(progressBar);
 
    this.loadNetwork = function(callBack) {
        var xhr = Ti.Network.createHTTPClient();
        xhr.setTimeout(30000);
 
        xhr.onload = function() {
            callBack(JSON.parse(this.responseText));
            currentWindow.remove(carregando);
            currentWindow.remove(progressBar);
        }
        xhr.ondatastream = function() {
            var length = this.getResponseHeader("Content-Length");
            length = length / 100;
            if(length > 0) {
                progressBar.message = "Carregando ".length;
                progressBar.value = length;
            }
        };
        xhr.onerror = function() {
 
            var aviso = Titanium.UI.createAlertDialog({
                title : "Problema de conexão",
                message : "Verifique sua conexão com a internet, tempo limite atingido",
                buttonNames : ['OK']
            })
            aviso.show();
 
            aviso.addEventListener('click', function(e) {
                currentWindow.close();
            });
        };
        xhr.open("POST", url);
        xhr.send({
            "dados" : dados,
            "tipo" : tipo
        });
    }
}

Did you ever found the problem? Seems I see something similar when using createScrollView and adding images inside.

Yes, I have found the answer.

In my case, changing the layout from 'vertical' to 'horizontal' (or just erasing the "layout: 'vertical'" propertie from the view, solved the problem... but I couldn't figure out why exactly this happened...

Your Answer

Think you can help? Login to answer this question!