title: Passing bundle from ListView to Adapter, Android
body: <p>I have a listview of locations, from which I want users to select from.</p>
  
  <p>After they select an item, I want the app to return specific entries based on that location..because I want to display a set of information in the ListView, I am using an Adapter; in the Result List, I am setting up to pass the array as a bundle:</p>
  
  <pre><code>//when listItem is clicked
      protected void onListItemClick(ListView l, View v, int position, long id) {
          super.onListItemClick(l, v, position, id);
  
          //in checked, in listview get Item positions for checked items
          SparseBooleanArray checked = l.getCheckedItemPositions();
  
          //assign selected items to new String ArrayList
          List&lt;String&gt; selectedItem = new ArrayList&lt;String&gt;();
  
  
          //determine size of items checked (number)
          for (int i = 0; i &lt; checked.size(); i++) {
              // Item position in adapter
              position = checked.keyAt(i);
              // Add location if it is checked i.e.) == TRUE!
              if (checked.valueAt(i))
                  //add selected items to madapter
                  selectedItem.add(madapter.getItem(position));
          }
  
          //create string output array, store new string array with selected items
          String[] outputStrArr = new String[selectedItem.size()];
  
          for (int i = 0; i &lt; selectedItem.size(); i++) {
              outputStrArr[i] = selectedItem.get(i);
          }
  
          Intent intent = new Intent(getApplicationContext(),
                  CustomMidwifeAdapter.class);
  
          // Create a bundle object
          Bundle b = new Bundle();
  
  
          b.putStringArray("selectedItems", outputStrArr);
  
          // Add the bundle to the intent.
          intent.putExtras(b);
  
          Intent intentstart = new Intent(getApplicationContext(),
                  MidwifeResultList.class);
  
  
  
          // start the ResultActivity
          startActivity(intentstart);
  
  
      }
  </code></pre>
  
  <p>As you can see, my instincts are to pass the data to the adapter because that is where I am querying the Parse data:</p>
  
  <pre><code>public class CustomMidwifeAdapter extends ParseQueryAdapter&lt;ParseObject&gt; {
  
  
  
        public static final String TAG = CustomMidwifeAdapter.class.getSimpleName();
  
          protected Context mContext;
          protected List&lt;ParseUser&gt; mUsers;
          protected ParseRelation&lt;ParseObject&gt; mMidwiferyfirm;
          protected ParseUser mCurentUser;
  
          Bundle b = getIntent().getExtras();
  
          //store selected items in array
          String[] resultArr = b.getStringArray("selectedItems");
  
  
  
  
          public CustomMidwifeAdapter(Context context)    {
              super(context, new ParseQueryAdapter.QueryFactory&lt;ParseObject&gt;() {
                  public ParseQuery create() {
  
                      // Here we can configure a ParseQuery to display
                      // midwives
                      ParseQuery query = new ParseQuery("midwifefirm");
                      query.whereEqualTo("userType", "midwife");
  
                      return query;
                  }
              });
          }
  </code></pre>
  
  <p>However, I am getting an error, cannot resolve method getIntent...I am thinking this is because I am not able to use it unless within an Activity..I could pass it to my ListActivity, but then I am not sure how to use it in my ParseQuery.</p>
  
  <p>I've looked around for answers, and there was some reference to needing to use the context, but not sure if that applied to my problem.</p>
  
  <p>Here is my MidwifeListActivity</p>
  
  <pre><code>public class MidwifeResultList extends ListActivity {
  
  
      public static final String TAG = MidwifeResultList.class.getSimpleName();
  
      private ParseQueryAdapter&lt;ParseObject&gt; mainAdapter;
  
      protected ParseRelation&lt;ParseUser&gt; mPatientRelation;
      protected ParseUser mCurrentUser;
  
  
  
      protected List&lt;ParseObject&gt; mMidwife;
  
      private CustomMidwifeAdapter midwifeListAdapter;
  
      //calls Adapter; Adapter manages data model
      //adapts it to individual entries in widget
      //inflates, assigns it to rows
      ArrayAdapter&lt;String&gt; madapter;
  
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
  
  
          //initialize main ParseQueryAdapter
          mainAdapter = new CustomMidwifeAdapter(this);
  
          //which keys in Midwife object
          mainAdapter.setTextKey("practicename");
          mainAdapter.setTextKey("education");
          mainAdapter.setTextKey("yearsinpractice");
          mainAdapter.setTextKey("practicephilosophy");
  
  
          mCurrentUser = ParseUser.getCurrentUser();
          mPatientRelation = mCurrentUser.getRelation(ParseConstants.KEY_PATIENT_RELATION);
  
  
          setListAdapter(mainAdapter);
          mainAdapter.loadObjects();
  
  
  
  
      }
  
  
      protected void onListItemClick (ListView l, View v, int position, long id)  {
  
          super.onListItemClick(l, v, position, id);
  
  
        if (getListView().isItemChecked(position)) {
  
  
  
  
  
            mCurrentUser.saveInBackground(new SaveCallback() {
                @Override
  
  
                public void done(ParseException e) {
  
                    if (e != null) {
  
                        Log.e(TAG, e.getMessage());
                    }
  
                }
            });
  
            Intent intent = new Intent(this, SelectedMidwife.class);
            intent.putExtra("practicename", "practicename");
            startActivity(intent);
  
        }
  
          else {
            //remove friend
  
        }
  
  
  
  
      }
  
  }
  </code></pre>