2013-05-19 109 views
0

我有一個小型的遊戲,我正在努力,我正在嘗試將一個Progress Bar作爲一個Xp Bar。我有一切設置,但東西不會移動Progress Bar not loading?

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

它可能是你的while循環(mProgressStatus < XPNEXT)進入一個無限循環。在while循環開始之後,mProgressStatus或XPNEXT值將如何改變?這個代碼中不清楚。