2013-03-15 3 views
1

진행률 막대를 사용하고 있지만 계속 진행률이 표시되지 않습니다. 초록색 막대가 나타나며 연속 진행 (즉, 10 회 진행)이 표시되지 않습니다.막대에 진행률 막대가 진행률을 표시하지 않습니다.

private ProgressBar mProgress; 
private int mProgressStatus = 0; 

private Handler mHandler = new Handler(); 

protected void onCreate(Bundle icicle) { 
    super.onCreate(icicle); 

    setContentView(R.layout.fetchee_distance); 
    mProgress = (ProgressBar) findViewById(R.id.p); 

    Thread timer = new Thread() { 
     public void run() { 
      try { 
       sleep(1000); 
       while (mProgressStatus < 100) { 
        mProgress.setProgress(mProgressStatus); 
        // mProgress.setMax(100); 
        mProgressStatus += 10; 

        System.out.println("count" + mProgressStatus); 

       } 
      } catch (InterruptedException e) { 
       e.printStackTrace(); 
      } finally { 
       /* 
       * Intent openMainList = new Intent(StartPoint.this, 
       * in.isuru.caf.MainList.class); 
       * startActivity(openMainList); 
       */ 
      } 
     } 
    }; 
    timer.start(); 
} 
+1

나는 당신의 수면이 당신의 루프에 있어야한다고 생각합니다. – njzk2

답변

1
그냥 바로 바의 전체 100 %를 보여주는에 반복을 통해 정말 빠른 진행과 결과를 어디 코드 그것을 먼저 잠있어 다음 while 루프에가는 루프

이전 수면 스레드에 대신 자고.

private ProgressBar mProgress; 개인 int mProgressStatus = 0;

개인 처리기 mHandler = new Handler();

보호 된 void onCreate (번들 고드름) { super.onCreate (고드름);

setContentView(R.layout.fetchee_distance); 
mProgress = (ProgressBar) findViewById(R.id.p); 

Thread timer = new Thread() { 
    public void run() { 
     try { 

      while (mProgressStatus < 100) { 
        sleep(1000);//Sleep moved to while thread 
       mProgress.setProgress(mProgressStatus); 
       // mProgress.setMax(100); 
       mProgressStatus += 10; 

       System.out.println("count" + mProgressStatus); 

      } 
     } catch (InterruptedException e) { 
      e.printStackTrace(); 
     } finally { 
      /* 
      * Intent openMainList = new Intent(StartPoint.this, 
      * in.isuru.caf.MainList.class); 
      * startActivity(openMainList); 
      */ 
     } 
    } 
}; 
timer.start(); } 
관련 문제