2017-05-03 68 views
-1

我創建一個包含片段的導航抽屜,每個片段需要幾次加載。 所以我要像下面的Gmail應用程序在過渡期間實現了一圈進度條:screenshot gmail app圓形進度條在兩個片段之間轉換

主要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,「工作完成」,Snackbar.LENGTH_LONG).setAction(「Action」,null).show();「因爲它在我的項目中是紅色的 –

+0

Snackbar是一個彈出式消息,如屏幕底部出現的烤麪包,v是傳遞的視圖參數,如果您在實施快餐欄時遇到問題,則只需執行Toast消息。 – Athelon