2012-01-15 3 views
0

나는 안드로이드 애플 리케이션을 만드는 중간에 있으며, 인스턴트 메신저 내 애플 리케이션을위한 소개로 사용 계획입니다. 진행률 표시 줄을 첫 번째보기로 사용하는 자습서를 나에게 알려줄 수 있습니까? 진행률 표시 줄이 완료되면 새로운보기로 진행합니다.진행률 표시 줄을 사용하여 안드로이드의 첫 번째보기

+0

진행률 표시 줄이 표시되는 동안 또는 정보를 표시하고 싶습니까? –

+0

가능하다면 선생님. – Vhal

답변

0

AsyncTask을 사용하는 것이 좋습니다. 이렇게하면 백그라운드 작업을 수행하고 진행률 표시 줄을 통해 UI를 업데이트 할 수 있습니다.

사용법에 대한 빠른 자습서가 있습니다.

private class InsertDataTask extends AsyncTask<Void, Void, Void> { 
    private final ProgressDialog dialog = new ProgressDialog(Main.this); 

    // can use UI thread here, and you see we add a progress dialog 
    protected void onPreExecute() { 
    this.dialog.setMessage("Inserting data..."); 
    this.dialog.show(); 
    } 

// automatically done on worker thread (separate from UI thread) 
    protected Void doInBackground(Void... args) { 
    //Do background work here 
    return null; 
    } 

    // can use UI thread here and we dismiss the progress dialog 
    protected void onPostExecute(final Void unused) { 
    if (this.dialog.isShowing()) { 
     this.dialog.dismiss(); 
    } 
관련 문제