title: How to read row values on gridview click event and pass them to another fragment
body: <p>I have a grid view with 3 columns in it in Fragment A.  I want to read the first column value on a click event and pass the value to FragmentB.</p>
  
  <p>How can I read the fisrst column of the the row clicked on the gridview?</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_flight, container, false);
      // Inflate the layout for this fragment
      grid = (GridView) view.findViewById(R.id.gridView);
      MyAdapter myAdapter = new MyAdapter(getActivity());
      grid.setAdapter(myAdapter);
      grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                                  int position, long id) {
              String place= (String) grid.getItemAtPosition(position);
              //How to read the first column value of the row clicked?
          }
  
      });
  
      return view;
  
  }
  </code></pre>
  
  <p>grid_row.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal"&gt;
      &lt;TextView
          android:id="@+id/Destination"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"/&gt;
      &lt;TextView
          android:id="@+id/Date"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"/&gt;
      &lt;TextView
          android:id="@+id/Description"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>fragment_flight.xml</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
  android:layout_height="match_parent" tools:context="com.test.FlightFragment"&gt;
  
  &lt;!-- TODO: Update blank fragment layout --&gt;
  
  &lt;GridView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/gridView"
      android:layout_gravity="left|top"
      android:numColumns="3"
      android:horizontalSpacing="10dp"
      android:verticalSpacing="10dp"
      android:stretchMode="columnWidth"
      android:columnWidth="100dp"
  
     /&gt;
  </code></pre>
  
  <p>
  After adding the code </p>
  
  <pre><code>grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                                  int position, long id) {
              if (position==0||position%3==0)
              {
                String place= (String) grid.getItemAtPosition(position);
                interfaceDataCommunicator.SendMarkerPlaceInfo(place);
              }
  
          }
  </code></pre>
  
  <p>I am having the error  </p>
  
  <blockquote>
  <pre><code>FATAL EXCEPTION: main
      java.lang.ClassCastException: com.test.FlightFragment cannot be cast to java.lang.String
              at com.test.FlightFragment.onItemClick(BurnScheduleFragment.java:51)
              at android.widget.AdapterView.performItemClick(AdapterView.java:301)
              at android.widget.AbsListView.performItemClick(AbsListView.java:1539)
              at android.widget.AbsListView$PerformClick.run(AbsListView.java:3332)
              at android.widget.AbsListView$1.run(AbsListView.java:4554)
              at android.os.Handler.handleCallback(Handler.java:725)
              at android.os.Handler.dispatchMessage(Handler.java:92)
              at android.os.Looper.loop(Looper.java:176)
              at android.app.ActivityThread.main(ActivityThread.java:5279)
  </code></pre>
  </blockquote>
  
  <p>AdapterClass</p>
  
  <pre><code> class MyAdapter extends BaseAdapter {
  
      ArrayList&lt;Schedule&gt; list;
      private Context context;
  
      MyAdapter(Context context) {
          this.context = context;
          list = new ArrayList();
          Resources resources = context.getResources();
          String[] tempDestination = resources.getStringArray(R.array.Destination);
          String[] tempDate = resources.getStringArray(R.array.Date);
          String[] tempDescription = resources.getStringArray(R.array.Description);
          for(int count=0;count&lt;4;count++ ){
              Flight tempFlight = new Flight(tempDestination[count],tempDate[count],tempDescription[count]);
              list.add(tempFlight);
          }
      }
  </code></pre>
  
  <p>View getView method</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
          Schedule tempFlight = list.get(position);
          ViewHolder holder;
          if (convertView == null) {
              convertView = LayoutInflater.from(context).inflate(R.layout.grid_row, parent, false);
              holder = new ViewHolder();
              holder.Destination = (TextView) convertView.findViewById(R.id.Destination);
              holder.Description = (TextView) convertView.findViewById(R.id.description);
              holder.Time =(TextView) convertView.findViewById(R.id.Date);
              convertView.setTag(holder);
          }
  
          else {
              holder = (ViewHolder) convertView.getTag();
          }
          holder.Destination.setText(tempFlight.Destination);
          holder.Description.setText(tempFlight.Description);
          holder.Time.setText(tempFlight.Time);
  
          return convertView;
      }
  </code></pre>