Action bar not shown in Android Studio

前端 未结 3 1446
生来不讨喜
生来不讨喜 2021-01-27 19:48

I\'m using Android Studio for the first time and can\'t manage to make the ActionBar show when I run the app. Here\'s what I have so far:

My Activity Ma

3条回答
  •  不要未来只要你来
    2021-01-27 20:17

    you must call you actionBar almost similar to how you would inflate a view and remember to use tool bar

    Toolbar toolbar = (Toolbar)this.findViewById(R.id.action_bar);
          if(toolbar!=null){
    
          }
          //getSupportActionBar().setHomeButtonEnabled(true);
          getSupportActionBar().setDisplayShowHomeEnabled(true);
          getSupportActionBar().setDisplayUseLogoEnabled(true);
    
          getSupportActionBar().setLogo(R.drawable.ic__actionbar);
    
          // Set up the action bar.
          final ActionBar actionBar = getSupportActionBar();
          if (showTabs) actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    
          // Create the adapter that will return a fragment for each of the three
          // primary sections of the activity.
    

提交回复
热议问题