Reputation: 4297
I need to sequentially show a changing text with 1 second or half a second between changes. How can i achieve this without using threads in android?
Upvotes: 3
Views: 1523
Reputation: 6311
I would just use a handler and a runnable in your activity, fairly simple
Handler textNextHandler = new Handler();
final Runnable textTimer = new Runnable()
{
public void run()
{
// ROTATE YOUR TEXT HERE THEN TELL IT HOW LONG TO DELAY UNTIL NEXT
textNextHandler.postDelayed(this, 500);
}
};
@Override
public void onResume() {
super.onResume();
textNextHandler.postDelayed(textTimer,500);
}
@Override
public void onPause() {
super.onPause();
textNextHandler.removeCallbacks(textTimer);
}
Upvotes: 3