我有一个正在开发的小游戏,我正在尝试将进度条作为 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();
我很确定一切都设置正确。但它根本不加载?我以前有这个工作,但不是它只是不起作用。有任何想法吗?