Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Basically what I want to achieve is to refresh the ListView when the users clicks on the 3rd column, which means its value changes (has been clicked or has not been). In the same time I wish to update the DB and the SharedPrefereces (I could create a new object of both classes and recover from the application context, but that seems pretty heavy).</p> </blockquote> <p>First of all, you shouldn't be implementing that logic in the <code>newView</code> method because that method will not be called for every row due to the recycling. The <code>newView</code> should be used only to build a new row view and nothing more. Use the <code>bindView</code> method for any row logic.</p> <p>Regarding the code in the <code>onClick</code> method I don't see where do you have problems. Update the database based on your logic and then query again the database for a <code>Cursor</code> with the new data and then use <code>swapCursor()</code> to update the adapter with the new values. This should work but it's not the recommended way mainly because you're doing every database operation on the main UI thread. Don't use the <code>startManagingCursor</code> method because this method runs the queries on the main UI thread, instead have a look at implementing a <a href="http://developer.android.com/guide/components/loaders.html" rel="nofollow"><code>Loader</code></a> in your activity to load data off the main UI thread. With a <code>Loader</code> you'll update the database values and then simply restart the <code>Loader</code> to update the list.</p> <blockquote> <p>I also wish to know if there is a way to trigger one of the implemented methods in one activity when an AlertDialog has been opened (in the same app, I actually want to add an element to my database through an AlertDialog and make the Activity that poped it up retrieve a new cursor and refresh its List).</p> </blockquote> <p>You're not saying anything about how you show that <code>AlertDialog</code>. If you want to update the list after you add the new element then use the listeners for the <code>AlertDialog</code>'s buttons and the same code as above.</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.
 

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