Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What you do is set the <code>ListView</code>'s <a href="http://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener.html" rel="nofollow"><code>OnItemClickListener</code></a> with the <a href="http://developer.android.com/reference/android/widget/AdapterView.html#setOnItemClickListener%28android.widget.AdapterView.OnItemClickListener%29" rel="nofollow"><code>setOnItemClickListener</code></a> method. You then obtain the "item object" for the clicked item with the <a href="http://developer.android.com/reference/android/widget/AdapterView.html#getItemAtPosition%28int%29" rel="nofollow"><code>getItemAtPosition</code></a> method:</p> <pre><code>listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parentView, View itemView, int position, long id) { ListView listView = (ListView) parentView; Object o = listView.getItemAtPosition(position); //... } }); </code></pre> <p>The type of the "item object" (<code>o</code> in the example above) depends on the <a href="http://developer.android.com/reference/android/widget/ListAdapter.html" rel="nofollow"><code>ListAdapter</code></a> that the list view is using. One common choice is <code>CursorAdapter</code>, in which case the type of the item object is conveniently the <a href="http://developer.android.com/reference/android/database/Cursor.html" rel="nofollow"><code>Cursor</code></a> to the record corresponding to the list item that was clicked.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload