Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Instead of using id as extra with intent,you should use the position of the item in list.</p> <p>The position will be similar to the position of the same record in your cursor so you just need to move your cursor to that position and fetch the detail you need from the same.Then you can display it on activity,as you have shown on your second activity view.</p> <p>so in your SearchDetails.class,you need to do:</p> <pre><code> ... int position=getIntent.getIntExtra("position",999); // 999 is default value Cursor cursor = db.rawQuery(&lt;query which you fired for populating search results in previous activity&gt;); if (cursor.getCount()&gt; 0 &amp;&amp; position!=999){ cursor.moveToPosition(position); ...body // fetch details and display it. } backButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { position--; //display details code Cursor cursor = db.rawQuery(&lt;query which you fired for populating search results in previous activity&gt;); if (cursor.getCount()&gt; 0 &amp;&amp; position!=-1){ cursor.moveToPosition(position); ...body // fetch details and display it. } } } nextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { position++; //display details code Cursor cursor = db.rawQuery(&lt;query which you fired for populating search results in previous activity&gt;); if (cursor.getCount()&gt; 0 &amp;&amp; position!=cursor.getCount()){ cursor.moveToPosition(position) ...body // fetch details and display it. } } } ... </code></pre> <p><strong>EDIT :</strong></p> <p>Revised code: ( repeated code removed)</p> <pre><code>... int position=getIntent.getIntExtra("position",999); // 999 is default value Cursor cursor = db.rawQuery(&lt;query which you fired for populating search results in previous activity&gt;); if (cursor.getCount()&gt; 0 &amp;&amp; position!=999){ cursor.moveToPosition(position); ...body // fetch details and display it. } backButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { position--; if (position!=-1){ cursor.moveToPosition(position); ...body // fetch details and display it. } } nextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { position++; if (position!=cursor.getCount()){ cursor.moveToPosition(position) ...body // fetch details and display it. } } } ... </code></pre>
    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.
    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