Thursday 15 August 2013

android - How to add tags to my fragments during initialising them inside a view pager adapter -


This is my code; The adviewer, the dataviewer and the settings viewer are my piece squares. I want to give a tag during intialising each method so that I can use them within some other piece or main activation.

  import java.util.ArrayList; Import java.util.HashMap; Import android.support.v4.app.Fragment; Import android.support.v4.app.FragmentManager; Import android.support.v4.app.FragmentPagerAdapter; Import android.view.ViewGroup; Public Category View Pager Adapter FragmentPagerAdapter {ArrayList & lt; Fragment & gt; ARF; Public Viewpage Adapter (Fragment Manager FM) {Super (FM); // Tudo Auto-Generated Producer Stub Array = New Arrestist & lt; Piece & gt; (); Arf.add (new datatyur ()); Arf.add (new AddViewer ()); Arf.add (new settings () ()); } @ Override Public Fragment Mill Itam (Int. 2) {// Todo Auto-Generated Method Stub Returns arf.get (arg0); } @ Override Public Inaccount () {// Todo Auto-Generated Method Stub Returns arf.size (); }}  

Use instantiateItem (...) and lostteam (... ) The way you can construct / construct your piece / destruction, or you can always organize your bundle (Bundle B) during construction. East.

  Private Spacer & lt; Piece & gt; Registered Fragment = New Sparse Array & lt; & Gt; (); @ Override public object instantiateItem (ViewGroup container, int position) {piece piece = (fragment) super.instantiateItem (container, position); // TODO Check whether you want it to be that type, and tagged registered fragmentation. Set input (position, piece); Return piece; } @ Override Public Null destroyed item (ViewGroup container, int position, object object) {super.destroyItem (container, position, object); RegisteredFragments.remove (status); }  

No comments:

Post a Comment