I am very new to Android. I used Javabefore, but not about a year and a half. I'm having problems updating the screen, or rather, with TextView. I browsed the network for hours for solutions, and I know why it does not work, but I do not know how to fix it.
public class PreliminaryActivity extends Activity {
int i = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getWindow().setBackgroundDrawableResource(R.drawable.background);
mainComputations();
}
public void mainComputations(){
runOnUiThread(new Runnable(){
public void run(){
TextView tv = (TextView) findViewById(R.id.time_display);
tv.setText(new Integer(i).toString());
i++;
}
});
}
I turned off my program so that it just increments the int value on the screen for testing, and it still won't work. Instead, it simply displays "0". If I add a for loop before the method runOnUiThread(), it will increase the value of i, but I feel that it just increases the value and then displays it, rather than updating it in real time. Any help would be greatly appreciated.