title: How to retrieve informations about an item clicked in a FragmentList
body: <p>I would like to start a profile activity when the user clicks on an item of a listFragment.
  The list shows different informations about users such as: name, id, ranking...</p>
  
  <p>What I'm looking for is a way to get access to the informations about the item clicked and pass the id of the user selected in the list to an intent.</p>
  
  <p>An AsyncTask retrieves infos from the server and calls the adapter in order to show the details of the user in the list item. If I use in the onListItemClick:</p>
  
  <pre><code>    Object o=(Object)getListView().getItemAtPosition(position);
      Log.e("LikeAttend Report", "Clicked list item: " + position + " Content: " + o.toString());
  </code></pre>
  
  <p>the log returns: </p>
  
  <blockquote>
    <p>Clicked list item: 1 Content: {score=7540, id=4, name= Gepp}</p>
  </blockquote>
  
  <p>How can I get the id value within the method to add an Extra to the intent and start the profile activity?</p>
  
  <p>I haven't found anything useful in the reference <a href="http://developer.android.com/reference/java/lang/Object.html" rel="nofollow">http://developer.android.com/reference/java/lang/Object.html</a></p>
  
  <p><strong>Code:</strong> </p>
  
  <p>This is what I've tried so far:</p>
  
  <pre><code>public static class LikeFragmentList extends ListFragment 
      {
          private ListView listLike;
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
          {
              View likeView = inflater.inflate(R.layout.likelist, container, false);
              ProgressBar progress = (ProgressBar) likeView.findViewById(R.id.loading_spinner_like);
              String tabSocial="like";
              listLike = (ListView) likeView.findViewById(android.R.id.list);
              /*
               *  The asyncTask retrieves infos about the user list
               */
              new AsyncLoadSocial(getActivity(), progress, listLike).execute(uid,tabSocial);
              return likeView;
  
          }
  
          @Override
          public void onListItemClick(ListView listView, View view, int position, long id) 
          {
              super.onListItemClick (listView, view, position, id);
              // I've tried with object and cursor
              Object o = (Object) getListView().getItem(position);
              //Cursor cursor = (Cursor) getListAdapter().getItem(position); NullPointerException
              Log.e("LikeAttend Report", "Clicked list item: " + position + " Content: " +o.toString());
  
              Intent intent = new Intent(getActivity(), Profile.class);
              //intent.putExtra("id", o.toString(0)); NullPointerException
              getActivity().startActivity(intent);
  
          }
      }
  </code></pre>
  
  <p><em><strong>First Solution proposed</em></strong>
  from Emmanuel.</p>
  
  <p>In the ListFragmentList:</p>
  
  <blockquote>
    <p></p>
  </blockquote>
  
  <pre><code>@Override
              public void onListItemClick(ListView listView, View view, int position, long id) 
              {
                  super.onListItemClick (listView, view, position, id);
                  String infos = getListView().getItemAtPosition(position).toString();
                  String[] info = infos.split("=");
                  Log.e("LikeAttend Report", "Clicked list item: " + position + " Content: total -&gt; " + infos + " \n Info[2] is:" + info[2]);
  
                  Intent intent = new Intent(getActivity(), Profile.class);
                  //intent.putExtra("id", o.toString(0));
                  getActivity().startActivity(intent);
  
              }
  </code></pre>
  
  <p>The log returns:</p>
  
  <blockquote>
    <p>Clicked list item: 2 Content: total -> {score=0, id=12, photo=,
    name=Beatrice Fratocchi} Info[2] is:  <strong>12, photo</strong></p>
  </blockquote>
  
  <p>in which the desired info is 12.  </p>
  
  <p><strong>* Second Solution proposed *</strong></p>
  
  <pre><code>    @SuppressWarnings("unchecked")
      @Override
      public void onListItemClick(ListView listView, View view, int position, long id) 
      {
          super.onListItemClick (listView, view, position, id);
  
          HashMap&lt;String, String&gt; map = (HashMap&lt;String, String&gt;) getListView().getItemAtPosition(position);
          Log.e("LikeAttend Report", "Clicked list item: " + position +" Content: \n" + map.get(TAG_ID).toString());
  
          Intent intent = new Intent(getActivity(), Profile.class);
          intent.putExtra("id", map.get(TAG_ID));
          getActivity().startActivity(intent);
  
      }
  </code></pre>