Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all your Fragments needs to return a instance of the Fragment, you can do this by adding a newInstance(Bundle args); Then you can update the Fragment depending on the postion in the ViewPager with FragmentArguments.</p> <pre><code>public class CustomList extends SherlockListFragment{ int fragment_position_in_viewpager = 0; .... public static CustomList newInstance(Bundle args) { customlist fragment = new CustomList(); fragment.setArguments(args); return fragment; } .... public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { fragment_position_in_viewpager = getArguments().getInt("position"); } String[] params = {xmlURLArray[fragment_position_in_viewpager]} new getFeed().execute(params); } protected Document doInBackground(String... params) { XMLParser parser = new XMLParser(); String xml = parser.getXmlFromUrl(params[0]); // getting XML from URL .... @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate( R.layout.layout_custom_list, container, false); //initialize your widgets here //button = (Button) root.findViewById(R.id.button); return root; } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final int fragment_position_in_viewpager; if (getArguments() != null) { fragment_position_in_viewpager = getArguments().getInt("position"); } //Update the Fragment UI depending on the ViewPager Position. .... </code></pre> <p>Then in your TestFragmentAdapter (FragmentPagerAdaper)</p> <pre><code>.... @Override public Fragment getItem(int position) { //Return a Fragment //from a new Instance with FragmentArguments Bundle args = new Bundle(); args.putInt("position", position); return CustomList.newInstance(args); //use a switch if you have different types Fragments //switch(position) { //case 0: //From the Fragment Constructor // return (mCustomList = new CustomList()); .... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload