java - Android toolbar inside a tab menu retrieval -
how menu toolbar inside fragment (tab)? i'm relatively new android , java.
here's code:
import android.os.bundle; import android.support.annotation.nullable; import android.support.v4.app.fragment; import android.support.v7.app.actionbaractivity; import android.support.v7.widget.toolbar; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; public class tab1 extends fragment { @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { view view =inflater.inflate(r.layout.tab_1,container,false); toolbar toolbar = (toolbar) view.findviewbyid(r.id.tool_bar); actionbaractivity activity = (actionbaractivity) getactivity(); activity.setsupportactionbar(toolbar); return view; } }
move toolbar activity , use oncreateoptionsmenu()
in fragment inflate menu need , add sethaoptionsmenu(true)
in oncreate()
of fragment.
Comments
Post a Comment