title: Create a tab indicator for a stack of fragments
body: <p>I have an activity, and a bunch of fragments in it. The fragments are not transitioned by sliding, but by button click. I'm trying to build a tab indicator like the one in the bottom that shows which fragment the user is. I don't even know how it's called.</p>
  
  <p>This is my main Activity where all the fragments belong, and with the actionbar menu the user navigates throught the fragments. In the activity it's switched straight to the first fragment out of 4 fragments (DetailsFragment)</p>
  
  <pre><code>public class CreateWorkoutActivity extends AppCompatActivity implements View.OnClickListener {
  
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_create_workout);
  
      DetailsFragment fragment = new DetailsFragment();
      getSupportFragmentManager().beginTransaction()
              .replace(R.id.create_activity_frameLayout, fragment)
              .addToBackStack(null)
              .commit();
  
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
  
      switch (item.getItemId()) {
          case android.R.id.home:
              FragmentManager fm = getSupportFragmentManager();
  
              if (fm.getBackStackEntryCount() &gt; 0) {
                  fm.popBackStack();
              }
              return true;
      }
      return false;
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/xWw8D.png" rel="nofollow noreferrer">image example</a></p>