Can't get Action Bar in fragment class

后端 未结 5 383
深忆病人
深忆病人 2020-12-15 16:11

I have an activity with three fragment classes inside it. I get an error when trying to change the action bar title from inside of them. If I try to make the classes just pu

5条回答
  •  难免孤独
    2020-12-15 16:22

    @Robert Estivil If you are using AppCompatActivity then use this:

    actionBar = ((AppCompatActivity)getActivity()).getSupportActionBar();
    

提交回复
热议问题