Temporary view

Former Member
Former Member
Hi,
I wanted to know how to add a temporary view that disappear after a little while ;exactly like the lap in the running application for example : when there is a lap, you have a view that shows the number of the lap and the time elapsed (for example), and this view disappears automatically.

Thanks for your help.

Rgds
  • I provided code some time ago to display an alert that would automatically disappear after a timeout or after a key press. I've made a small change to it to follow new guidelines for the SDK, but it should still work to show what you need to do.

    You can find it here.

    Travis
  • Former Member
    Former Member over 8 years ago
    Ok, many thanks, I'll have a look on it.

    Rgds,
  • Former Member
    Former Member over 8 years ago
    Hi Travis,
    I try to implement your code, but the alert never appears, I put System.println in every method of the Alert class, there is never called.

    Where must we implement the

    new Alert({
    :timeout => 2000,
    :font => Gfx.FONT_MEDIUM,
    :text => "Quick Brown Fox",
    :fgcolor => Gfx.COLOR_RED,
    :bgcolor => Gfx.COLOR_WHITE
    });



    I try on the onupdate(dc), but this didn't work too (I implement a datafield, maybe this is different ?)
  • In a DF, here's the way I'd handle this (I do the same in full blown apps, BTW).

    In onUpdate(), check for a "message screen", by looking for a non-zero value for something like "msgSeconds". If it's non-zero, display the message, else, display the regular screen.

    Then in compute(), if msgSeconds is non zero, do msgSeconds-- (compute() is called every second, so no timer needed (which you can't use in a DF anyway)).

    To display a message, (on what ever condition you want), you'd have something like:

    msg="message to display";
    msgSeconds=10;
  • Former Member
    Former Member over 8 years ago
    Hi jim_m_58,
    this is a very good idea !

    thanks !!
  • Sorry. I wasn't aware that you were trying to do this from within a data field. I don't believe that you can push views from data fields, so you'd have to implement something like Jim's suggestion.

    Travis
  • Former Member
    Former Member over 8 years ago
    Ok,
    no problem, I didn't tell it by the way.
    Jim suggestion is perfect, not to complicated for me :) I was able to implement it :)
    Thanks both.

    Rgds,