Back to project page Recipe-Puppy-Android.
The source code is released under:
Apache License
If you think the Android project Recipe-Puppy-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.jerin.magicrecipe.adapters; /* w w w . j a va 2 s.c om*/ import java.util.ArrayList; import com.jerin.magicrecipe.data.MagicRecipeConstants; import com.jerin.magicrecipe.data.RecipeItem; import com.jerin.magicrecipe.fragments.RecipePageFragment; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; /** * Pager Adapter which generates a fragment for each Recipe Item. * * @author jerin * */ public class RecipePagerAdapter extends FragmentStatePagerAdapter { private ArrayList<RecipeItem> recipeItems; public RecipePagerAdapter(FragmentManager fm) { super(fm); } /** * Set ArrayList of Recipe Items to adapter. * * @param recipeItems */ public void setData(ArrayList<RecipeItem> recipeItems) { this.recipeItems = recipeItems; notifyDataSetChanged(); } @Override public Fragment getItem(int index) { RecipePageFragment recipePageFragment = new RecipePageFragment(); Bundle args = new Bundle(); args.putParcelable(MagicRecipeConstants.MAGICRECIPE_FRAGMENT_ARGS_KEY, recipeItems.get(index)); recipePageFragment.setArguments(args); return recipePageFragment; } @Override public int getCount() { if (null == recipeItems) { return 0; } return recipeItems.size(); } }