Posts

Showing posts with the label android-activity

Same Toolbar for all activities - Something I'm missing

Image
Same Toolbar for all activities - Something I'm missing What I want: I want to keep same toolbar for all my activities. What I have tried: I made a BaseActivity and I'm having toolbar in it. I'm extending other activities to BaseActivity. What is the issue: When I run the app. I'm not finding toolbar to other activities. Below is my code. BaseActivity.java public class BaseActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_base); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.toolbar_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()){ case R.id.menu_lang_english: ...

Same Navigation Drawer in different Activities

Same Navigation Drawer in different Activities I made a working navigation drawer like it's shown in the tutorial on the developer.android.com website. But now, I want to use one Navigation Drawer, i created in the NavigationDrawer.class for multiple Activities in my Application. My question is, if anyone here can make a little Tutorial, which explains, how to use one Navigation drawer for multiple Activities. I read it first at this Answer Android Navigation Drawer on multiple Activities but it didn't work on my Project public class NavigationDrawer extends Activity { public DrawerLayout drawerLayout; public ListView drawerList; private ActionBarDrawerToggle drawerToggle; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = new ActionBarDrawerToggle((Activity) this, drawerLayout, R.drawable.ic_drawer, 0, 0) { public void onDrawerClosed(View vie...