hi Spirolateral!
Maybe the demo I made below could help you:
Using java Syntax Highlighting
public class myActivityName extends Activity {
public static sview sv;
public static Activity instance;
public Handler handler = new Handler(){
public void handleMessage(Message msg) {
sv.changeBG(0, 255, 0);
sv.invalidate();
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
instance = this;
sv = new sview(this);
setContentView(sv);
Timer t = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
handler.sendEmptyMessage(0);
}
};
t.schedule(task,3000);
sv.changeBG(0, 0, 255);
sv.invalidate();
}
class sview extends SurfaceView{
public sview(Context context) {
super(context);
changeBG(255, 0, 0);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
}
public void changeBG(int r, int g, int b){
System.out.println("change bg: "+r+","+g+","+b);
setBackgroundColor(Color.rgb(r, g, b));
invalidate();
}
}
}
Parsed in 0.034 seconds, using
GeSHi 1.0.8.4
Basically I use Handler to made the changes and to invalidate the view.
In the demo I put BG color as red when the view is created.
change to blue right after it create timer and run it.
and change to green when the timer trigger the task.