android - Toolbar in fragment doesn't display its title -
the style of activity "theme.appcompat.light.noactionbar". there toolbar in fragment, added activity later.
i cannot set title of actionbar. codes below don't work. please me. how set title of toolbar in fragment?
//in fragment @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment_main2, container, false); toolbar toolbar = (toolbar) rootview.findviewbyid(r.id.toolbar); int = getarguments().getint(arg_section_number); toolbar.settitle("aaa"); ((appcompatactivity) getactivity()).setsupportactionbar(toolbar); charsequence title = ((appcompatactivity) getactivity()).getsupportactionbar().gettitle(); ((appcompatactivity) getactivity()).getsupportactionbar().setdisplayhomeasupenabled(true);
try
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment_main2, container, false); toolbar toolbar = (toolbar) rootview.findviewbyid(r.id.toolbar); int = getarguments().getint(arg_section_number); ((appcompatactivity) getactivity()).setsupportactionbar(toolbar); charsequence title = ((appcompatactivity) getactivity()).getsupportactionbar().gettitle(); ((appcompatactivity) getactivity()).getsupportactionbar().setdisplayhomeasupenabled(true);
Comments
Post a Comment