2017-05-03 4 views
-1

フラグメントを含むナビゲーション・ドロワーを作成します。各フラグメントはロードに数時間かかります。 だから私は以下のGmailアプリのような遷移中の円のプログレスバーを実装する:screenshot gmail app2つのフラグメント間の遷移の円進行バー

メインActivity.class

public boolean onNavigationItemSelected(MenuItem item) { 

    int id = item.getItemId(); 
    if (id == R.id.profil) { 

    } 
    else if (id == R.id.accueil) { 

     AccueilFragment fragment = new AccueilFragment(); 
     android.support.v4.app.FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); 
     fragmentTransaction.replace(R.id.fragment1, fragment); 
     fragmentTransaction.commit(); 
     floatingActionButton.show(); 
     getSupportActionBar().setTitle("Accueil"); 


    } else if (id == R.id.categories) { 
     CategoriesFragment fragment = new CategoriesFragment(); 
     android.support.v4.app.FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); 
     fragmentTransaction.replace(R.id.fragment1, fragment); 
     fragmentTransaction.commit(); 
     floatingActionButton.hide(); 
     getSupportActionBar().setTitle("Categories"); 


    } 
} 

答えて

0
private ProgressDialog mProgressDialog; 

mProgressDialog = new ProgressDialog(this); 

mProgressDialog.setMessage("Working ..."); 

private void doSomeWorkMethod() { 

    mProgressDialog.show(); 

    doSomeWork . . . 

    mProgressDialog.dismiss(); 

    Snackbar.make(v, "Work Complete.", Snackbar.LENGTH_LONG) 
     .setAction("Action", null).show(); 
} 
+0

ものだと、** V **スナックバー「を意味します。 make(v、 "Work Complete"、Snackbar.LENGTH_LONG).setAction( "Action"、null).show(); "それは私のプロジェクトでは赤色になります –

+0

スナックバーは、画面の下部に表示されるトーストのようなポップアップメッセージです。vは、渡されたビューパラメータです。スナックバーの実装に問題がある場合は、代わりにトーストメッセージを実装します。 – Athelon

関連する問題