我有一个小游戏,我正在努力,我正在尝试将进度条作为Xp栏。我已经设置了所有东西,但事情不会移动
private static final int PROGRESS = 0x1;
private ProgressBar mProgress;
private Handler mHandler = new Handler();
private int mProgressStatus;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.play_screen);
mProgress = (ProgressBar) findViewById(R.id.xpBar);
mProgress.setMax(Integer.parseInt(textViewXpNextLevel.getText().toString()));
new Thread(new Runnable() {
public void run() {
int xp = Integer.parseInt(textViewXPValue.getText().toString());
int XPNEXT = Integer.parseInt(textViewXpNextLevel.getText().toString());
while (mProgressStatus < XPNEXT) {
mProgressStatus = xp;
mHandler.post(new Runnable() {
public void run() {
mProgress.setProgress(mProgressStatus);
}
});
}
}
}).start();
我很确定一切都设置正确。但它根本不加载?我之前有这个工作,但不是它不起作用。任何想法?
答案 0 :(得分:0)
可能是你的while循环(mProgressStatus&lt; XPNEXT)进入无限循环。在while循环启动后,mProgressStatus或XPNEXT值将如何变化?这段代码并不清楚。