NullPointerException when getting AppBarLayout and call setFitsSystemWindows()2019 Community Moderator ElectionGet screen dimensions in pixelsStatic way to get 'Context' in Android?Is there a way to get the source code from an APK file?How to get the build/version number of your Android application?Get current time and date on AndroidonActivityResult is not being called in FragmentAndroid - tiled backgrounds occasionally get stretchedAndroid - Google Maps API v2 - NoClassDefFoundErrorAndroid Studio Layout ErrorsOnClickListener not working with fragments

How could a female member of a species produce eggs unto death?

redhat 7 + How to stop systemctl service permanent

Best mythical creature to use as livestock?

Is it illegal in Germany to take sick leave if you caused your own illness with food?

Co-worker team leader wants to inject the crap software product of his friends into our development. What should I say to our common boss?

Welcoming 2019 Pi day: How to draw the letter π?

If Invisibility ends because the original caster casts a non-concentration spell, does Invisibility also end on other targets of the original casting?

Is all copper pipe pretty much the same?

What is the difference between "shut" and "close"?

Want to switch to tankless, but can I use my existing wiring?

Rejected in 4th interview round citing insufficient years of experience

Running a subshell from the middle of the current command

My adviser wants to be the first author

What has been your most complicated TikZ drawing?

US to Europe trip with Montreal layover - is 52 minutes enough?

Making a sword in the stone, in a medieval world without magic

Why must traveling waves have the same amplitude to form a standing wave?

Time dilation for a moving electronic clock

Does Linux have system calls to access all the features of the file systems it supports?

validation vs test vs training accuracy, which one to compare for claiming overfit?

Excess Zinc in garden soil

Do Bugbears' arms literally get longer when it's their turn?

Potentiometer like component

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?



NullPointerException when getting AppBarLayout and call setFitsSystemWindows()



2019 Community Moderator ElectionGet screen dimensions in pixelsStatic way to get 'Context' in Android?Is there a way to get the source code from an APK file?How to get the build/version number of your Android application?Get current time and date on AndroidonActivityResult is not being called in FragmentAndroid - tiled backgrounds occasionally get stretchedAndroid - Google Maps API v2 - NoClassDefFoundErrorAndroid Studio Layout ErrorsOnClickListener not working with fragments










0















I am trying to make StatusBar transparent. Here's setTransparentStatusbar():



public void setTransparentStatusbar() 
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow().setStatusBarColor(Color.TRANSPARENT);
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.main_appbar);
Toolbar toolbar = findViewById(R.id.main_toolbar);
appBarLayout.setFitsSystemWindows(true);
toolbar.setFitsSystemWindows(true);
toolbar.getLayoutParams().height = (int)getResources().getDimension(R.dimen.toolbar_height) + SizeUtil.getStatusBarHeight(this);




I use class BaseActivity to set up toolbars for all child activities. In child activities' onCreate() I use super.setContentViewAndSetUpToolBar() instead of setContentView(), Here's parts of setContentViewAndSetUpToolBar(int layoutResID):



setContentView(layoutResID);
// Init Toolbar
androidx.appcompat.widget.Toolbar toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar);
androidx.appcompat.widget.Toolbar toolbar_lower = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar_lower);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);

// Set ic icon
ActionBar actionBar = getSupportActionBar();
if (actionBar != null)
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.mipmap.twotone_event_note_white_24);

setTransparentToolbar();


Here's main_toolbar.xml file:



<?xml version="1.0" encoding="utf-8"?>

<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_appbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>

<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:visibility="visible"
>

<LinearLayout
android:id="@+id/title_div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="#fff"
android:textSize="@dimen/toolbar_title"
android:visibility="visible"
android:layout_marginRight="16dp"
/>

</LinearLayout>

</androidx.appcompat.widget.Toolbar>


</com.google.android.material.appbar.AppBarLayout>


Here's activity's xml file:



<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/root_coordinatorlayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#fff"
android:fitsSystemWindows="true">

<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>



<!--Main layout-->
...
<!--Main layout END-->

</androidx.coordinatorlayout.widget.CoordinatorLayout>

<include
layout="@layout/circle_one_drawer"/>

</androidx.drawerlayout.widget.DrawerLayout>


When I call setTransparentStatusbar(), program throws NullPointerException, here's error info:



Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.appbar.AppBarLayout.setFitsSystemWindows(boolean)' on a null object reference
at com.example.elmliu.uniport.activity.BaseActivity.setTransparentToolbar(BaseActivity.java:532)
at com.example.elmliu.uniport.activity.BaseActivity.setContentViewAndSetUpToolBar(BaseActivity.java:101)
at com.example.elmliu.uniport.activity.visual.CircleThree.onCreate(CircleThree.java:34)
at android.app.Activity.performCreate(Activity.java:6662)









share|improve this question
























  • Can you show the whole activity code?

    – Themelis
    Mar 7 at 11:10











  • whenever you use Appbar layout make sure that wrap up in Coordinate layout.

    – Tanveer Munir
    Mar 7 at 11:12















0















I am trying to make StatusBar transparent. Here's setTransparentStatusbar():



public void setTransparentStatusbar() 
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow().setStatusBarColor(Color.TRANSPARENT);
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.main_appbar);
Toolbar toolbar = findViewById(R.id.main_toolbar);
appBarLayout.setFitsSystemWindows(true);
toolbar.setFitsSystemWindows(true);
toolbar.getLayoutParams().height = (int)getResources().getDimension(R.dimen.toolbar_height) + SizeUtil.getStatusBarHeight(this);




I use class BaseActivity to set up toolbars for all child activities. In child activities' onCreate() I use super.setContentViewAndSetUpToolBar() instead of setContentView(), Here's parts of setContentViewAndSetUpToolBar(int layoutResID):



setContentView(layoutResID);
// Init Toolbar
androidx.appcompat.widget.Toolbar toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar);
androidx.appcompat.widget.Toolbar toolbar_lower = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar_lower);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);

// Set ic icon
ActionBar actionBar = getSupportActionBar();
if (actionBar != null)
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.mipmap.twotone_event_note_white_24);

setTransparentToolbar();


Here's main_toolbar.xml file:



<?xml version="1.0" encoding="utf-8"?>

<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_appbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>

<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:visibility="visible"
>

<LinearLayout
android:id="@+id/title_div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="#fff"
android:textSize="@dimen/toolbar_title"
android:visibility="visible"
android:layout_marginRight="16dp"
/>

</LinearLayout>

</androidx.appcompat.widget.Toolbar>


</com.google.android.material.appbar.AppBarLayout>


Here's activity's xml file:



<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/root_coordinatorlayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#fff"
android:fitsSystemWindows="true">

<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>



<!--Main layout-->
...
<!--Main layout END-->

</androidx.coordinatorlayout.widget.CoordinatorLayout>

<include
layout="@layout/circle_one_drawer"/>

</androidx.drawerlayout.widget.DrawerLayout>


When I call setTransparentStatusbar(), program throws NullPointerException, here's error info:



Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.appbar.AppBarLayout.setFitsSystemWindows(boolean)' on a null object reference
at com.example.elmliu.uniport.activity.BaseActivity.setTransparentToolbar(BaseActivity.java:532)
at com.example.elmliu.uniport.activity.BaseActivity.setContentViewAndSetUpToolBar(BaseActivity.java:101)
at com.example.elmliu.uniport.activity.visual.CircleThree.onCreate(CircleThree.java:34)
at android.app.Activity.performCreate(Activity.java:6662)









share|improve this question
























  • Can you show the whole activity code?

    – Themelis
    Mar 7 at 11:10











  • whenever you use Appbar layout make sure that wrap up in Coordinate layout.

    – Tanveer Munir
    Mar 7 at 11:12













0












0








0








I am trying to make StatusBar transparent. Here's setTransparentStatusbar():



public void setTransparentStatusbar() 
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow().setStatusBarColor(Color.TRANSPARENT);
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.main_appbar);
Toolbar toolbar = findViewById(R.id.main_toolbar);
appBarLayout.setFitsSystemWindows(true);
toolbar.setFitsSystemWindows(true);
toolbar.getLayoutParams().height = (int)getResources().getDimension(R.dimen.toolbar_height) + SizeUtil.getStatusBarHeight(this);




I use class BaseActivity to set up toolbars for all child activities. In child activities' onCreate() I use super.setContentViewAndSetUpToolBar() instead of setContentView(), Here's parts of setContentViewAndSetUpToolBar(int layoutResID):



setContentView(layoutResID);
// Init Toolbar
androidx.appcompat.widget.Toolbar toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar);
androidx.appcompat.widget.Toolbar toolbar_lower = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar_lower);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);

// Set ic icon
ActionBar actionBar = getSupportActionBar();
if (actionBar != null)
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.mipmap.twotone_event_note_white_24);

setTransparentToolbar();


Here's main_toolbar.xml file:



<?xml version="1.0" encoding="utf-8"?>

<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_appbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>

<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:visibility="visible"
>

<LinearLayout
android:id="@+id/title_div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="#fff"
android:textSize="@dimen/toolbar_title"
android:visibility="visible"
android:layout_marginRight="16dp"
/>

</LinearLayout>

</androidx.appcompat.widget.Toolbar>


</com.google.android.material.appbar.AppBarLayout>


Here's activity's xml file:



<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/root_coordinatorlayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#fff"
android:fitsSystemWindows="true">

<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>



<!--Main layout-->
...
<!--Main layout END-->

</androidx.coordinatorlayout.widget.CoordinatorLayout>

<include
layout="@layout/circle_one_drawer"/>

</androidx.drawerlayout.widget.DrawerLayout>


When I call setTransparentStatusbar(), program throws NullPointerException, here's error info:



Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.appbar.AppBarLayout.setFitsSystemWindows(boolean)' on a null object reference
at com.example.elmliu.uniport.activity.BaseActivity.setTransparentToolbar(BaseActivity.java:532)
at com.example.elmliu.uniport.activity.BaseActivity.setContentViewAndSetUpToolBar(BaseActivity.java:101)
at com.example.elmliu.uniport.activity.visual.CircleThree.onCreate(CircleThree.java:34)
at android.app.Activity.performCreate(Activity.java:6662)









share|improve this question
















I am trying to make StatusBar transparent. Here's setTransparentStatusbar():



public void setTransparentStatusbar() 
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow().setStatusBarColor(Color.TRANSPARENT);
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.main_appbar);
Toolbar toolbar = findViewById(R.id.main_toolbar);
appBarLayout.setFitsSystemWindows(true);
toolbar.setFitsSystemWindows(true);
toolbar.getLayoutParams().height = (int)getResources().getDimension(R.dimen.toolbar_height) + SizeUtil.getStatusBarHeight(this);




I use class BaseActivity to set up toolbars for all child activities. In child activities' onCreate() I use super.setContentViewAndSetUpToolBar() instead of setContentView(), Here's parts of setContentViewAndSetUpToolBar(int layoutResID):



setContentView(layoutResID);
// Init Toolbar
androidx.appcompat.widget.Toolbar toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar);
androidx.appcompat.widget.Toolbar toolbar_lower = (androidx.appcompat.widget.Toolbar) findViewById(R.id.main_toolbar_lower);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);

// Set ic icon
ActionBar actionBar = getSupportActionBar();
if (actionBar != null)
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.mipmap.twotone_event_note_white_24);

setTransparentToolbar();


Here's main_toolbar.xml file:



<?xml version="1.0" encoding="utf-8"?>

<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_appbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>

<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:visibility="visible"
>

<LinearLayout
android:id="@+id/title_div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="#fff"
android:textSize="@dimen/toolbar_title"
android:visibility="visible"
android:layout_marginRight="16dp"
/>

</LinearLayout>

</androidx.appcompat.widget.Toolbar>


</com.google.android.material.appbar.AppBarLayout>


Here's activity's xml file:



<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/root_coordinatorlayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#fff"
android:fitsSystemWindows="true">

<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>



<!--Main layout-->
...
<!--Main layout END-->

</androidx.coordinatorlayout.widget.CoordinatorLayout>

<include
layout="@layout/circle_one_drawer"/>

</androidx.drawerlayout.widget.DrawerLayout>


When I call setTransparentStatusbar(), program throws NullPointerException, here's error info:



Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.appbar.AppBarLayout.setFitsSystemWindows(boolean)' on a null object reference
at com.example.elmliu.uniport.activity.BaseActivity.setTransparentToolbar(BaseActivity.java:532)
at com.example.elmliu.uniport.activity.BaseActivity.setContentViewAndSetUpToolBar(BaseActivity.java:101)
at com.example.elmliu.uniport.activity.visual.CircleThree.onCreate(CircleThree.java:34)
at android.app.Activity.performCreate(Activity.java:6662)






android






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 1:49







Elm Liu

















asked Mar 7 at 10:58









Elm LiuElm Liu

217




217












  • Can you show the whole activity code?

    – Themelis
    Mar 7 at 11:10











  • whenever you use Appbar layout make sure that wrap up in Coordinate layout.

    – Tanveer Munir
    Mar 7 at 11:12

















  • Can you show the whole activity code?

    – Themelis
    Mar 7 at 11:10











  • whenever you use Appbar layout make sure that wrap up in Coordinate layout.

    – Tanveer Munir
    Mar 7 at 11:12
















Can you show the whole activity code?

– Themelis
Mar 7 at 11:10





Can you show the whole activity code?

– Themelis
Mar 7 at 11:10













whenever you use Appbar layout make sure that wrap up in Coordinate layout.

– Tanveer Munir
Mar 7 at 11:12





whenever you use Appbar layout make sure that wrap up in Coordinate layout.

– Tanveer Munir
Mar 7 at 11:12












1 Answer
1






active

oldest

votes


















0














Problem solved.
In main_toolbar.xml, id main_appbar was given. However,



<include
android:id="@+id/circle_one_appbar"
layout="@layout/main_toolbar"/>


the new id circle_one_appbar will overwrite the old id. Thus, I shouldn't use id main_appbar to find the AppBarLayout.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042179%2fnullpointerexception-when-getting-appbarlayout-and-call-setfitssystemwindows%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Problem solved.
    In main_toolbar.xml, id main_appbar was given. However,



    <include
    android:id="@+id/circle_one_appbar"
    layout="@layout/main_toolbar"/>


    the new id circle_one_appbar will overwrite the old id. Thus, I shouldn't use id main_appbar to find the AppBarLayout.






    share|improve this answer



























      0














      Problem solved.
      In main_toolbar.xml, id main_appbar was given. However,



      <include
      android:id="@+id/circle_one_appbar"
      layout="@layout/main_toolbar"/>


      the new id circle_one_appbar will overwrite the old id. Thus, I shouldn't use id main_appbar to find the AppBarLayout.






      share|improve this answer

























        0












        0








        0







        Problem solved.
        In main_toolbar.xml, id main_appbar was given. However,



        <include
        android:id="@+id/circle_one_appbar"
        layout="@layout/main_toolbar"/>


        the new id circle_one_appbar will overwrite the old id. Thus, I shouldn't use id main_appbar to find the AppBarLayout.






        share|improve this answer













        Problem solved.
        In main_toolbar.xml, id main_appbar was given. However,



        <include
        android:id="@+id/circle_one_appbar"
        layout="@layout/main_toolbar"/>


        the new id circle_one_appbar will overwrite the old id. Thus, I shouldn't use id main_appbar to find the AppBarLayout.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 13:19









        Elm LiuElm Liu

        217




        217





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042179%2fnullpointerexception-when-getting-appbarlayout-and-call-setfitssystemwindows%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

            2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme