Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>there are many ways to solve your problem. One possible solution is this: you simply need to implement protected method onListItemClick(ListView l, View v, int position, long id) in your ListActivity. </p> <pre><code>public class Database extends ListActivity { //YOUR CODE ABOVE HERE... public static final String SHOWITEMINTENT_EXTRA_FETCHROWID = "fetchRow"; public static final int ACTIVITY_SHOWITEM = 0; /*Intent request user index*/ @Override protected void onListItemClick(ListView l, View v, int position, long id){ /* position variable holds the position of item you clicked... do your stuff here. If you want to send to another page, say another activity that shows your stuff, you can always use an intent example: */ Intent tmpIntent = new Intent(this, YourActivityForShowingItem.class); tmpIntent.putExtra(SHOWITEMINTENT_EXTRA_FETCHROWID, position); startActivityForResult(tmpIntent, ACTIVITY_SHOWITEM); } } </code></pre> <p>Alternately, you can access the ListView of your listActivity using getListView(), and call the setters for listeners or context menu as you would have done with a regular ListView object. For instance, this function that sets a listener using this approach: </p> <pre><code>private void setMyListListener(){ getListView().setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView&lt;?&gt; a, View v, int position, long id){ /*same fake code as above for calling another activity using an intent:*/ Intent tmpIntent = new Intent(this, YourActivityForShowingItem.class); tmpIntent.putExtra(SHOWITEMINTENT_EXTRA_FETCHROWID, position); startActivityForResult(tmpIntent, ACTIVITY_SHOWITEM); } }); } </code></pre> <p>This function can be called by your onCreate(...) function afterwards if you want your click listener to be configured the same way for the whole duration of your activity.</p>
    singulars
    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.
 

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