onCreate, MyActivity will display five TextViews. After you touch one of the five TextViews, it will hide three to four TextViews and color one red and one green or just color one green.
I can code everything up to here. But how can I pause for a few seconds and then repopulate the five TextViews with new values, unhide them and make them all white?
Thanks in advance!
NEW EDIT NEW EDIT NEW EDIT
I tried a Timer in a new project and can attach the code and make my question less vague.
Here is the main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/hello"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
Here is the TestTimer.java
package com.somecompany.android.testtimer;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class TestTimer extends Activity {
TextView hello;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
hello = (TextView)findViewById(R.id.hello);
hello.setTextColor(Color.rgb(0,255,0));
new Reminder(5);
}
void resetAndContinue() {
Log.d("TESTTIMER", "Start resetAndContinue...");
hello.setTextColor(Color.rgb(255,255,255));
Log.d("TESTTIMER", "End resetAndContinue...");
}
class Reminder {
Timer timer;
public Reminder(int seconds) {
timer = new Timer();
timer.schedule(new RemindTask(), seconds*1000);
}
class RemindTask extends TimerTask {
public void run() {
Log.d("TESTTIMER", "Ran TagRemindTask");
resetAndContinue();
timer.cancel(); //Terminate the timer thread
}
}
}
}
The issue is that the Timer executes resetAndContinue and logs two entries, but it doesn't set the TextView color from green to white and it doesn't log anymore
07-15 13:08:46.894: DEBUG/TESTTIMER(618): Ran TagRemindTask
07-15 13:08:46.894: DEBUG/TESTTIMER(618): Start resetAndContinue...
07-15 13:08:47.264: DEBUG/dalvikvm(524): GC freed 202 objects / 8936 bytes in 156ms
07-15 13:08:52.224: DEBUG/dalvikvm(210): GC freed 43 objects / 2096 bytes in 85ms