android - Add a view to a fragment from mainActivity -


I want to dynamically add pieces from this main activity. From
, the edit () API in the piece square, what other options are available to me.
I have tried to do fragment.getView () on line 1, but this nullier gives an exception. I do not have good information about piece APIs and there is no time to invest in it through it. Anyone can provide a solution to the problem.

Main activity.Java

  Public class increases main activity activity {@ Override secured zero on credit (saved bundle) InstanceState) {Super. Contents (Saved Instance State); SetContentView (R.layout.activity_main); Actionbar Bar = GetActionbar (); Bar.setNavigationMode (ActionBar.NAVIGATION_MODE_TABS); Actionbars Tab tab A = bar.notube (). SetText ("A Tab"); Actionbars Tab tab b = bar.notube (). SetText ("B Tab"); Actionbars Tab tabs = bar.notube (). Settext ("c-tab"); Piece segment A = new afraagmentabab (); Piece segment B = new BFragmentTab (); Piece piece C = new CFragmentTab (); TabA.setTabListener (new MyTabsListener (fragmentA)); TabB.setTabListener (new MyTabsListener (fragmentB)); TabC.setTabListener (new MyTabsListener (fragmentC)); Bar.addTab (Taba); Bar.addTab (TABB); Bar.addTab (tabC); // Line 1 // How to see one of these sections here I / or modify the contents of that section} @ Override Public Boolean On Crate Option Menu (Menu Menu) {// Expand Menu; It adds the item to the Action Bar if it exists GetMenuInflater (). Flow (R. menu activation_men, menu); Back true; } Protected class MyTabsListener implementing ActionBar.TabListener {Private piece piece; Public matab listener {fragment} {this.fragment = fragment; } Tabs selected on public zeros (tab tabs, fragment Transaction Fault) {} Public tabs selected on public zeros (tab tab, piece transaction fee) {ft.add (r.de.framement, compiler, piece, blank); // should be done here except for modifications / ideas. } Public tabs on zero (Tab tab, fragment transaction fee) {// Some people also needed this line to do this work: ft.remove (fragment); }}}   

BFagmentTab.java

  increases the public square BFragmentTab piece {@ override public view onCreateView (LayoutInflater inflater, ViewGroup container, bundle saved instenstate) {return inflater.inflate (R. Late fragment_b, container, false); }}    

Try calling fragment.getView () onResume () or onStart () in the methods of activity.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -