getSupportActionBar from inside of Fragment ActionBarCompat

After Fragment.onActivityCreated(…) you’ll have a valid activity accessible through getActivity().

You’ll need to cast it to an ActionBarActivity then make the call to getSupportActionBar().

((AppCompatActivity)getActivity()).getSupportActionBar().setSubtitle(R.string.subtitle);

You do need the cast. It’s not poor design, it’s backwards compatibility.

Leave a Comment

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