https://www.cnblogs.com/mengdd/p/5590634.html
修改toolbar的title
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.news_fragment,container,false); setHasOptionsMenu(true); androidx.appcompat.widget.Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); ((AppCompatActivity)getActivity()).setSupportActionBar(toolbar); ((AppCompatActivity)getActivity()).getSupportActionBar().setTitle("近期新闻"); return view; }