I want the progressbar to increase when it matches a string. Like if I click yes, the yes bar will increase. But for some reason I am unable to make it progress.
Code:
public class result extends VoteActivity{
private ProgressBar mProgress;
private int mProgressStatus = 0;
private Handler mHandler = new Handler();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.alert);
if(choice=="Yes")
{
mProgress = (ProgressBar) findViewById(R.id.p1);
// Start lengthy operation in a background thread
new Thread(new Runnable() {
public void run() {
++mProgressStatus;
// Update the progress bar
mHandler.post(new Runnable() {
public void run() {
mProgress.setProgress(mProgressStatus);
}
});
}
}).start();
}
What am I doing wrong here?
You cannot compare strings with
==. You need to useequals():