title: Passing data from a fragment to a custom adapter (for use with ListView)
body: <p>I'm trying to send data retrieved from a bundle within a fragment into a ListView's adapter so that the data can be displayed, depending on previous user choices. </p>
  
  <p>I can log that the correct data is being sent to my fragment, however when I try to pass that data into the constructor of my adapter the ListView doesn't get populated. I'm not sure if this is the correct way of going about getting the data to the adapter, especially since the data isn't coming from a cursor.</p>
  
  <p>In my fragment, this is the relevant code:</p>
  
  <pre><code>public class AddEditRecipeActivityFragment extends Fragment {
  ListView mListView;
  private IngredientListAdapter mIngredientListAdapter;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      Log.d(TAG, "onCreateView: starts");
      View view = inflater.inflate(R.layout.fragment_add_edit_recipe, container, false);
  
  
      mNameTextView = (EditText) view.findViewById(R.id.addedit_name);
      mAddItem = (ImageButton) view.findViewById(R.id.addGrocery);
      mDescriptionTextView = (EditText) view.findViewById(R.id.addedit_description);
      mMealType = (EditText) view.findViewById(R.id.addedit_meal);
      mSaveButton = (Button) view.findViewById(R.id.addedit_save);
  
      mListView = (ListView) view.findViewById(R.id.lstIngredient);
  
  
      Bundle arguments = getArguments();
  
      String addedGrocery = arguments.getString("GroceryName");
  
      String addedGroceryGrams = arguments.getString("grams");
  
      Log.d(TAG, "onCreateView: retrieved ingredient = " + addedGrocery
              + " retrieved amount = " + addedGroceryGrams );
  
     mIngredientListAdapter = new IngredientListAdapter(getActivity(), null,
              0, addedGrocery, addedGroceryGrams ) ;
      mListView.setAdapter(mIngredientListAdapter);
  
  
  .... }
  </code></pre>
  
  <p>This is my Adapter code, modified from the CursorAdapter class:</p>
  
  <pre><code>public class IngredientListAdapter  extends CursorAdapter {
  private static final String TAG = "IngredientListAdapter";
  
  private LayoutInflater mInflater;
  private Context mContext;
  private String mIngredient;
  private String mGrams;
  
  public IngredientListAdapter(Context context, Cursor c, int flags, String ingredient, String grams) {
      super(context, c, flags);
      mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      this.mIngredient = ingredient;
      this.mGrams = grams;
  }
  
  public View newView(Context context, Cursor cursor, ViewGroup parent) {
      View view = mInflater.inflate(R.layout.ingrediend_listview, parent, false);
      ViewHolder holder = new ViewHolder();
      holder.ingredient = (TextView) view.findViewById(R.id.ingredient);
      holder.amount = (TextView) view.findViewById(R.id.amount);
      view.setTag(holder);
  
      return view;
  }
  
  
  public void bindView(View view, Context context, Cursor cursor) {
      ViewHolder holder = (ViewHolder) view.getTag();
  
      Log.d(TAG, "bindView: Starts");
  
      Log.d(TAG, "bindView: ingredient = " + mIngredient);
  
      holder.ingredient.setText(mIngredient);
      holder.amount.setText(mGrams);
  
  
  }
  
  static class ViewHolder {
      TextView ingredient;
      TextView amount;
   }
  }
  </code></pre>
  
  <p>When I try to view the logs for my IngredientListAdapter class, nothing shows up at all. Which is strange because I have another adapter extending CursorAdapter and those logs are working - perhaps because they involve the cursor parameter?</p>
  
  <p>I'm clearly missing something important here, any help would be much appreciated!</p>