Note: I searched google and here for few hours, but didn't get the answer.
I want to show the value what will for loop
return. Here is my code:
mProgressBar = findViewById(R.id.progressBar);
percentText = findViewById(R.id.percent);
mProgressBar.setMax(100);
mProgressBar.setProgress(0);
new Thread(new Runnable() {
@Override
public void run() {
try{
for (int progress = 0; progress<100; progress++){
mProgressBar.setProgress(progress);
percentText.setText(progress);
sleep(30);
}
}catch (Exception e){
e.printStackTrace();
}finally {
Intent intent = new Intent(SplashScreenActivity.this, SignUpLoginActivity.class);
startActivity(intent);
}
App crashing while I'm adding this line percentText.setText(progress);
. Without this line, code is working well. What should I do to show the progress value to the TextView?