I'm a noob to Android and I am trying to cycle text from an arrayList of strings and display them in an textswitcher. I want the text to change every two seconds. i used this SO question as my guide and have no problem switching the text with a button. However, when I try to cycle the text with a for loop with a 2 second delay it only shows the first text from the arrayList. How can I make the loop continuously execute with a pause? Any help is greatly appreciated.
My Code;
private void updateCounter()
{
try{
for (int i=0; i< CoinShowReader.tickercontent.size(); i++){
mHandler.postDelayed(new Runnable() {
public void run() {
m_switcher.setText((CoinShowReader.tickercontent.get(CoinShowReader.m_counter)));
CoinShowReader.m_counter++;
}
}, 2000);
}
}catch(Exception e){
e.printStackTrace();
}
}