gpt4 book ai didi

java - 如何使进度条前进

转载 作者:行者123 更新时间:2023-11-29 07:14:12 25 4
gpt4 key购买 nike

我希望进度条在匹配字符串时增加。就像如果我点击是,是的栏会增加。但出于某种原因,我无法让它取得进展。

代码:

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();
}

我在这里做错了什么?

最佳答案

您不能将字符串与 == 进行比较。您需要使用 equals():

if(choice.equals("Yes"))

关于java - 如何使进度条前进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11107584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com