package ch.dissem.apps.abit; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.NavUtils; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.MenuItem; import com.mikepenz.materialize.MaterializeBuilder; /** * @author Christian Basler */ public abstract class DetailActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.scrolling_toolbar_layout); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Show the Up button in the action bar. //noinspection ConstantConditions getSupportActionBar().setDisplayHomeAsUpEnabled(true); new MaterializeBuilder() .withActivity(this) .withStatusBarColorRes(R.color.colorPrimaryDark) .withTranslucentStatusBarProgrammatically(true) .withStatusBarPadding(true) .build(); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // This ID represents the Home or Up button. In the case of this // activity, the Up button is shown. Use NavUtils to allow users // to navigate up one level in the application structure. For // more details, see the Navigation pattern on Android Design: // // http://developer.android.com/design/patterns/navigation.html#up-vs-back // NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class)); return true; default: return super.onOptionsItemSelected(item); } } }