how to use setSupportActionBar in fragment

前端 未结 1 1235
闹比i
闹比i 2020-12-08 09:48

I need to use the setSupportActionBar in fragment which I am unable to also I am unable to use setContentView please to help with it also Thankyou in advance the related cod

相关标签:
1条回答
  • 2020-12-08 10:07

    You can setSupportActionbar like this in fragments:

    ((AppCompatActivity)getActivity()).setSupportActionBar(mToolbar);
    

    You need to inflate tabbar_layout in onCreateView of Fragment. Like this:

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.tabbar_layout, container, false);
     //YOUR STUFF
    return rootView;
    }
    
    0 讨论(0)
提交回复
热议问题