title: Passing data from ListView to Fragment
body: <p>I have a <code>ListView</code> in my fist screen that shows some information. When I click on each item, I have another listView with new information and textview in the same page, I want to show the pervious list view row in text view,</p>
  
  <p>would you please let me know how can I implement this,</p>
  
  <p>Thanks in advance!</p>
  
  <p>here is my xml file</p>
  
  <pre><code>&lt;RelativeLayout 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="######"&gt;
  
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
  
      &lt;TextView
          android:id="@+id/header"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:visibility="gone"
          android:text="test" /&gt;
  
      &lt;TextView
          android:id="@+id/list_textview"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:visibility="gone"
          android:text="@string/no_message"
          android:textColor="#000000"
          android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
          android:gravity="center"&gt;&lt;/TextView&gt;
  
      &lt;ListView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/listView" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is my java file that shows the listview and </p>
  
  <pre><code> @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle  
  savedInstanceState) {
  
      View view = inflater.inflate(R.layout.fragment_main, container, false);
      listView = (ListView)view.findViewById(R.id.listView);
      listView.setOnItemClickListener(this);
  
      getActivity().getActionBar().setTitle(R.string.title_forms);
  
      TextView details = (TextView)view.findViewById(R.id.detail_header);
  
      details.setVisibility(View.VISIBLE);
  
      return view;
  }
  </code></pre>
  
  <p>Here is one of my fragment that has onItemClick Listener</p>
  
  <p>public class ListFragment extends Fragment implements AdapterView.OnItemClickListener {</p>
  
  <pre><code>public static final String TAG = "ListFragment";
  
  private ListView listView;
  private ArrayList&lt;String&gt; testIds;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setHasOptionsMenu(true);
      tripIds = new ArrayList&lt;String&gt;();
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_main, container, false);
      listView = (ListView) view.findViewById(R.id.listView);
      listView.setOnItemClickListener(this);
  
      registerForContextMenu(listView);
  
      return view;
  }
  </code></pre>
  
  <p>Here is my onItemClick :</p>
  
  <pre><code>@Override
  public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
      chooseTest(testIds.get(position));
  
      String selectedTestId = testIds.get(position);
  
      Helpers.saveToSharedPreferences(getActivity(),
              Constants_Prefs.SELECTED_TOP_LEVEL_RECORD,
              Constants_Keys.SELECTED_TEST_ID,
  
  
            selectedTestId);
  </code></pre>
  
  <p>I don't know how can I get that information</p>
  
  <pre><code>    FormTypeListFragment passDataTo = new FormTypeListFragment();
      Bundle bundle = new Bundle();
      bundle.putString("DATA", selectedTestId);
      passDataTo.setArguments(bundle);
  
  
  
  }
  </code></pre>