Here is what I want to do: I click on a button which opens and activity that changes the background periodically.
My code looks like this:
RelativeLayout relativeLayout;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.picscreen);
Thread background = new Thread(){
public void run(){
try {
sleep(2000);
relativeLayout = new RelativeLayout(this);
relativeLayout.setBackgroundResource(R.drawable.img10);
setContentView(relativeLayout);
}catch (Exception e){
}
}
};
background.start();
}protected void onDestroy(){
super.onDestroy();
}
The error says the relative Layout cannot ba applied to a thread. What do I do wrong?