How to hide action bar for fragment?

If you are using AppCompatActivity (you should) then this is the solution that worked for me:

((AppCompatActivity) getActivity()).getSupportActionBar().hide();

You can add this in onCreate(). The support fragment’s getActivity() returns a FragmentActivity, and this does not contain the getSupportActionBar() method. Using just getActionBar() gives null-pointer exception if you have AppCompatActivity.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)