I am trying to find a simular solution but this poster did not explain what R.id.products_list_linear I did R.id Tried to set .products_list_linear as my linear target id, in which I am trying to change the piece. But it just overlays 2 pieces on top of each other. I'm pretty sure that I need to get the container ID in the viewer, but I do not know how to get this ID
edited Do: To make it clear that I am trying to change one piece on one page page with another, my code almost looks almost like an answer, but when I do R.id.products_list_linear, I have a layout I am trying to change, I change a piece of the place, I'm trying to change it.
Replace the piece inside a visible pager Try this optimized viewer adapter, .. Call it from the activity in the form of a logic from the segment, When you replace the view / segment inside the viewPager, then
import java.util.List; Import android.support.v4.app.Fragment; Import android.support.v4.app.FragmentManager; Import android.support.v4.app.FragmentStatePagerAdapter; Import android.view.ViewGroup; Public Class ViewPagerAdapter FragmentStatePagerAdapter {Private list & lt; Piece & gt; Pieces = null; Private Fragment Manager Piece Manager = Faucet; Public ViewPagerAdapter (slice manager piece manager, list & lt; piece & gt; pieces) {super (piece manager); This.fragments = pieces; This.fragmentManager = fragmentManager; } @ Override public piece getItem (int position) {Return fragments.get (status); } @ Override public in receipt () {return pieces.image (); } @ Override public zero set primary item (see group container, int position, object object) {super .setPrimaryItem (container, 0, object); } @ Override Public Zero Notified Data Set (Tagged) {super.notifyDataSetChanged (); } @ Override Public Zero Blasted Items (ViewGroup Collection, Inte Status, Object View) {fragmentManager.executePendingTransactions (); FragmentManager.saveFragmentInstanceState (fragments.get (status)); } In place of public null (integer position, piece slice) {fragments.set (position, piece); This.notifyDataSetChanged (); }}
list & lt; Fragment & gt; Pieces = new vector & lt; Piece & gt; (); Fragments.add (Fragmente Instantiete (This, Fragment 1.class.Getnam ())); Fragments.add (Fragmente Instantiete (This, Fragment 2. Class.Getnam ())); Fragments.add (Fragmente Instantiete (This, Fragment 3. Class.Jetename ())); Fragments.add (Fragmente Instantiete (This, Fragment 4.class.Getnam ())); Fragments.add (fragmented constellation (this, fragment 5.clus.getnames ())); MPagerAdapter = New ViewPagerAdapter (getFragmentManager (), pieces);
mPagerAdapter.replaceItem (2, Fragment.instantiate (This, Fragment5.class .getName) ()));
No comments:
Post a Comment