Pour exécuter un petit traitement à intervalles de temps régulier :
static final int TIMING = 1000; // durée en ms
TextView tv = (TextView)findViewById(R.id.textview1);
Handler h = new Handler();
final Runnable r = new Runnable()
{
public void run()
{
// traitement ici
// code
tv.append("Salut !\n");
// Relance l'opération
h.postDelayed(this, TIMING);
}
}
// On lance une première fois :
h.postDelayed(r, TIMING);
Aucun commentaire:
Enregistrer un commentaire