Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: notifyDataSetChanged(); not working
    primarykey
    data
    text
    <p>I have a database in a server and from a Tablet I take some values from one table in the database. I load this information correctly into a list but I would like to know why when there is a change, nothing happens even if I use <code>notifyDataSetChanged();</code>. I must say that for loading the loading data y use the AsyncTaskClass So, my problem is that I don't know if use the notifyDataSetChanged(); method correctly ,because if there's is a change I would like to refresh the image. Here is some part of the code of the class:</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.all_candidatos); candidatosList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); new CargarCandidatos().execute(); } // public void timer(){ // new CountDownTimer(tiempo, 100) { // // public void onTick(long millisUntilFinished) { // // } // // public void onFinish() { // // new CargarCandidatos().execute(); // // } // }.start();} /** * Background Async Task to Load all product by making HTTP Request * */ class CargarCandidatos extends AsyncTask&lt;String, String, String&gt; { /** * Before starting background thread Show Progress Dialog * */ @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(Monitorizacion.this); pDialog.setMessage("Loading ..."); pDialog.setIndeterminate(false); pDialog.setCancelable(false); pDialog.show(); } /** * getting All products from url * */ protected String doInBackground(String... args) { List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); JSONObject json = jParser.makeHttpRequest(url_candidatos, "GET", params); Log.d("Candidatos: ", json.toString()); try { int success = json.getInt(TAG_SUCCESS); if (success == 1) { candidatos = json.getJSONArray(TAG_CANDIDATOS); for (int i = 0; i &lt; candidatos.length(); i++) { JSONObject c = candidatos.getJSONObject(i); // Storing each json item in variable String nserie = c.getString(TAG_NSERIE); String dni = c.getString(TAG_DNI); String nombre = c.getString(TAG_NOMBRE); String test = c.getString(TAG_TEST); String pregunta = c.getString(TAG_PREGUNTA); String bateria = c.getString(TAG_BATERIA); // creating new HashMap HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); // adding each child node to HashMap key =&gt; value map.put(TAG_NSERIE, nserie); map.put(TAG_DNI, dni); map.put(TAG_NOMBRE, nombre); map.put(TAG_TEST, test); map.put(TAG_PREGUNTA, pregunta); map.put(TAG_BATERIA, bateria); // adding HashList to ArrayList candidatosList.add(map); } } } catch (JSONException e) { e.printStackTrace(); } return null; } /** * After completing background task Dismiss the progress dialog * **/ protected void onPostExecute(String file_url) { pDialog.dismiss(); runOnUiThread(new Runnable() { public void run() { /** * Updating parsed JSON data into ListView * */ adapter = new SimpleAdapter( Monitorizacion.this, candidatosList, R.layout.list_item, new String[] { TAG_NSERIE, TAG_DNI, TAG_NOMBRE, TAG_TEST, TAG_PREGUNTA, TAG_BATERIA}, new int[] { R.id.id, R.id.dni, R.id.nombre, R.id.test, R.id.pregunta, R.id.bateria}); setListAdapter(adapter); adapter.notifyDataSetChanged(); // timer(); } }); } } } </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.
 

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