Android effective navigation showing inappropriate/duplicate lists inpages
<p>I am using the sample script given in android website for implementing the swipable listviews.
While i was trying to populate the listview inside the frament dyamically through webservices with the help of "Async" class,I should in appropriate data.</p>

<p>I am passing the id(networkid=1,networkid=2.,etc) to be called to the service from getview in the adapter and catching the id,calling and populating the listview through asynclass.</p>

<p>Problem:
-some times populating the list in fragment according to the id passed to the fragment,But some times its showing the first page list in the second page.(Duplicating) instead of showing the second pagelist in the secondpage list. </p>

<p>Can any one help in this.thanks in advance.</p>

<pre><code>package com.example.android.effectivenavigation;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class CollectionDemoActivity extends FragmentActivity {


    DemoCollectionPagerAdapter mDemoCollectionPagerAdapter;


    ViewPager mViewPager;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_collection_demo);


        mDemoCollectionPagerAdapter = new DemoCollectionPagerAdapter(
                getSupportFragmentManager());


        mViewPager = (ViewPager) findViewById(R.id.pager);
        mViewPager.setAdapter(mDemoCollectionPagerAdapter);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {


        }
        return super.onOptionsItemSelected(item);
    }


    public static class DemoCollectionPagerAdapter extends
            FragmentStatePagerAdapter {

        public DemoCollectionPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int i) {
            Fragment fragment = new DemoObjectFragment();
            Bundle args = new Bundle();
</code></pre>

<p><strong>//Sending the id of network to the frament here..</strong></p>

<pre><code>            args.putInt(DemoObjectFragment.ARG_OBJECT, i + 1); // Our object is

            fragment.setArguments(args);
            return fragment;
        }

        @Override
        public int getCount() {
            // For this contrived example, we have a 100-object collection.
            return 100;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return "OBJECT " + (position + 1);
        }
    }

    /**
     * A dummy fragment representing a section of the app, but that simply
     * displays dummy text.
     */
    public static class DemoObjectFragment extends Fragment {

        public static final String ARG_OBJECT = "object";

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(
                    R.layout.fragment_collection_object, container, false);
            Bundle args = getArguments();
</code></pre>

<p><strong>//catching the id and populating the list through async task from services here..</strong></p>

<pre><code>            ((TextView) rootView.findViewById(android.R.id.text1))
                    .setText(Integer.toString(args.getInt(ARG_OBJECT)));
            return rootView;
        }
    }
}
</code></pre>
