Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to refresh Activity from AsyncTask in Android
    text
    copied!<p>In my program I am retrieving values from a json URL and then displaying them in a listView. now i want to delete some items from the list, so when I click an Item then the delete API calls in the doInBackground() of AsyncTask.. Now after completing the AsyncTask I want to reload the list so that the changes can b seen.</p> <p>How can I relaod the list to see the changes..</p> <p>My AsyncTask is a separate class.</p> <p>this is my AsyncTask code:</p> <pre><code>protected String doInBackground(String... DATA) { // TODO Auto-generated method stub rqst_type = DATA[0]; if(rqst_type.equals("del_top5")) { String url = DATA[1]; JsonParser jParser = new JsonParser(); JSONObject json = jParser.getJSONfromUrl(url+memberId); Log.v(TAG_LOG, "del url: "+url+memberId); try { message = json.getString(TAG_DELSCS); Log.v(TAG_LOG, "msg "+TAG_DELSCS); } catch(JSONException e) { Log.v(TAG_LOG, String.valueOf(e)); } } return null; } protected void onPostExecute(String result) { // TODO Auto-generated method stub super.onPostExecute(result); if(rqst_type.equals("del_top5")) { if(message.equals("true")) { AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setTitle("Course Deleted"); alertDialog.setMessage("Course Sucessfully Deleted"); alertDialog.setIcon(R.drawable.tick); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); alertDialog.show(); } else if(message.equals("false")) { AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setTitle("Error"); alertDialog.setMessage("Course Not Deleted"); alertDialog.setIcon(R.drawable.alert); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); alertDialog.show(); } else { AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setTitle("Error"); alertDialog.setMessage("Unknown Erroe Occured"); alertDialog.setIcon(R.drawable.alert); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); alertDialog.show(); } } progress.dismiss(); } </code></pre> <p>The name of my Activity is <code>MyTop5.class</code> that I want to reload when I click the OK button of the AlertDialog..</p> <p>this is the coading for my ListAdapter:</p> <pre><code>ListAdapter adapter = new SimpleAdapter(this, LoadingScreen.top5List, R.layout.top5_list, new String[] { TAG_GLFCRSNAME, TAG_GLFCRSID, TAG_CRTDATE, TAG_FCLTY, TAG_HOLES }, new int[] { R.id.top_golfname, R.id.top_courseid, R.id.top_createdate, R.id.top_fclty, R.id.top_holes }); setListAdapter(adapter); </code></pre> <p>Thanks in Advance..</p>
 

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