android - How to open a view in a fragment with an onClick method? -


i have floating action button in layout, , open view when clicked. read this answer way handle click events this:

public class alltasksfragment extends fragment implements onclicklistener {  @override public view oncreateview(layoutinflater inflater, viewgroup container,                          bundle savedinstancestate) {     view rootview = inflater.inflate(r.layout.fragment_all_tasks, container, false);      floatingactionbutton fab = (floatingactionbutton) rootview.findviewbyid(r.id.fab);     fab.setonclicklistener(this);      return rootview; }  @override public void onclick(view rootview) {     switch (rootview.getid()) {         case r.id.fab:              setcontentview(r.layout.fragment_new_task);              break;     } }} 

but, because setcontentview method can't used in fragments, android studio returns error: cannot resolve method setcontentview(int).

what can use instead of setcontentview bring view through onclick method? or have approach in different way?


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -