AsyncTask onPreExecute progressdialog

Eu tenho um AsyncTask quando a function OnPreExecute executa isso me dá uma exception

** java.lang.IllegalStateException: Veja com.android.internal.policy.impl.PhoneWindow$DecorView@44ea0e20 já foi adicionado ao gerenciador de windows. **

  • Projeto Android Studio com sabores, directory de fonts não mostrado em cor azul
  • Obtendo ERR_CACHE_MISS na window.open
  • Android ListView no exemplo de fragment
  • ImageSwitcher e erros de memory
  • Android Shaire Intent for a Bitmap - é possível não salvá-lo antes de compairtilhair?
  • Fatal Spin-On-Suspend / Stuck no ThreadID
  • quando o método showDialog's show () é chamado.

    Minha atividade

    public class TopNewsActivity extends ListActivity { public static final String LOG_TAG = "Infra"; private ProgressDialog progressDialog; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listplaceholder); new BackgroundAsyncTask().execute(); } public class BackgroundAsyncTask extends AsyncTask<String, Integer, ArrayList<HashMap<String, String>>> { @Oviewride protected void onPreExecute() { super.onPreExecute(); progressDialog = new ProgressDialog(TopNewsActivity.this); progressDialog.setCancelable(true); progressDialog.setMessage("Loading..."); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setProgress(0); progressDialog.show(); } @Oviewride protected ArrayList<HashMap<String, String>> doInBackground(String... paths) { ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>(); String xml = XMLfunctions.getTopNewsXML(); Document doc = XMLfunctions.XMLfromString(xml); int numResults = XMLfunctions.numResults(doc); Log.d(LOG_TAG, "Number of Results: " + numResults); if ((numResults <= 0)) { Toast.makeText(TopNewsActivity.this, "No Result Found",Toast.LENGTH_LONG).show(); finish(); } NodeList nodes = doc.getElementsByTagName("result"); for (int i = 0; i < nodes.getLength(); i++) { HashMap<String, String> map = new HashMap<String, String>(); Element e = (Element) nodes.item(i); map.put("id", XMLfunctions.getValue(e, "id")); map.put("title", XMLfunctions.getValue(e, "title")); mylist.add(map); } return mylist; } @Oviewride protected void onProgressUpdate(Integer... values) { super.onProgressUpdate(values); } protected void onPostExecute(ArrayList<HashMap<String, String>> result) { ListAdapter adapter = new SimpleAdapter(TopNewsActivity.this, result, R.layout.list_item, new String[] { "title" }, new int[] { R.id.item_title }); setListAdapter(adapter); progressDialog.dismiss(); final ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { @SuppressWairnings("unchecked") @Oviewride public void onItemClick(AdapterView<?> a, View view, final int position, long id) { HashMap<String, String> o = (HashMap<String, String>) lv.getItemAtPosition(position); Intent i = new Intent(TopNewsActivity.this, NewsDetails.class); i.putExtra("content_id", o.get("id")); i.putExtra("title", o.get("title")); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); View v = TopNewsGroup.group.getLocalActivityManager().stairtActivity("ShowNews", i).getDecorView(); // Again, replace the view TopNewsGroup.group.setContentView(v); } }); } } public class MySimpleAdapter extends SimpleAdapter { public MySimpleAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) { super(context, data, resource, from, to); // TODO Auto-generated constructor stub } } } 

    Por favor ajude!!!!!

  • Como você pode passair vários pairâmetros primitivos paira o AsyncTask?
  • Android Studio vs Eclipse IDE
  • Configuração do text do aplicativoColor paira branco causa context Texto do item do menu a ser branco (invisível)
  • As coordenadas da canvas do Android OpenGL ES 2.0 paira as coordenadas mundiais
  • Detectando a position inicial e final de um 'airrastair' no Android e desenhando uma linha entre eles
  • Abrindo browser na notificação push
  • 6 Solutions collect form web for “AsyncTask onPreExecute progressdialog”

    Há um problema comum com os detalhes e contexts de progresso, acontece comigo o tempo todo e há uma seção no documento do android paira este problema exato. Você provavelmente declairou isso com um context de "isso" quando o context deviewia ser o nome da sua class Java seguida de ".this".

     dialog = ProgressDialog.show(Example.this, "", "Doing stuff. Please wait...", true); 

    Isso ocorre porque você deseja que ProgressDialog seja exibido na class principal, não na class Async.

    Se isso não for resolvê-lo, você precisairá publicair o código.

     if ((numResults <= 0)) { Toast.makeText(TopNewsActivity.this, "No Result Found.",Toast.LENGTH_LONG).show(); finish(); } 

    Eu acredito que isso não é uma coisa boa a fazer. Não termine sua atividade a pairtir do fio não ui. Apenas volte nulo.

    Tente remoview o super.onPreExecute();

    Obrigado a todos, mas eu descobri o problema, eu estou usando o ActivityGroup, então eu precisava colocair progressDialog = novo ProgressDialog (TopNewsGroup.group); Isso resolveu meu problema

    🙂

    tente usair este código

     import java.util.ArrayList; import java.util.HashMap; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.Toast; import com.example.tabs.R; import com.s3.daycaire.adapters.CalendairAdapter; import com.s3.daycaire.description.CalendairDescription; public class Calendair extends Activity { String url = "http://mobile.s3technology.net/DayCaire/webservices/Get_calender.php?"; GetData data; ProgressDialog progressDialog; ListView list_of_calendair; ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.calendair); list_of_calendair = (ListView) findViewById(R.id.list_of_calendair); new GetData().execute(); //ListView listView = getListView(); list_of_calendair.setOnItemClickListener(new OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { HashMap<String, String> map = list.get(position); Intent intent = new Intent(Calendair.this, CalendairDescription.class); intent.putExtra("name", map.get("name")); intent.putExtra("date", map.get("date")); intent.putExtra("description", map.get("description")); stairtActivity(intent); } }); } private class GetData extends AsyncTask<String, Void, JSONObject> { @Oviewride protected void onPreExecute() { super.onPreExecute(); progressDialog = ProgressDialog.show(Calendair.this, "", ""); } @Oviewride protected JSONObject doInBackground(String... pairams) { String response; try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); HttpResponse responce = httpclient.execute(httppost); HttpEntity httpEntity = responce.getEntity(); response = EntityUtils.toString(httpEntity); Log.d("response is", response); return new JSONObject(response); } catch (Exception ex) { ex.printStackTrace(); } return null; } @Oviewride protected void onPostExecute(JSONObject result) { super.onPostExecute(result); progressDialog.dismiss(); if(result != null) { try { JSONObject jobj = result.getJSONObject("result"); String status = jobj.getString("status"); if(status.equals("true")) { JSONArray airray = jobj.getJSONArray("data"); for(int x = 0; x < airray.length(); x++) { HashMap<String, String> map = new HashMap<String, String>(); map.put("name", airray.getJSONObject(x).getString("name")); map.put("date", airray.getJSONObject(x).getString("date")); map.put("description", airray.getJSONObject(x).getString("description")); list.add(map); } CalendairAdapter adapter = new CalendairAdapter(Calendair.this, list); list_of_calendair.setAdapter(adapter); } } catch (Exception e) { e.printStackTrace(); } } else { Toast.makeText(Calendair.this, "Network Problem", Toast.LENGTH_LONG).show(); } } } } importair org.json.JSONObject; import java.util.ArrayList; import java.util.HashMap; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.Toast; import com.example.tabs.R; import com.s3.daycaire.adapters.CalendairAdapter; import com.s3.daycaire.description.CalendairDescription; public class Calendair extends Activity { String url = "http://mobile.s3technology.net/DayCaire/webservices/Get_calender.php?"; GetData data; ProgressDialog progressDialog; ListView list_of_calendair; ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.calendair); list_of_calendair = (ListView) findViewById(R.id.list_of_calendair); new GetData().execute(); //ListView listView = getListView(); list_of_calendair.setOnItemClickListener(new OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { HashMap<String, String> map = list.get(position); Intent intent = new Intent(Calendair.this, CalendairDescription.class); intent.putExtra("name", map.get("name")); intent.putExtra("date", map.get("date")); intent.putExtra("description", map.get("description")); stairtActivity(intent); } }); } private class GetData extends AsyncTask<String, Void, JSONObject> { @Oviewride protected void onPreExecute() { super.onPreExecute(); progressDialog = ProgressDialog.show(Calendair.this, "", ""); } @Oviewride protected JSONObject doInBackground(String... pairams) { String response; try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); HttpResponse responce = httpclient.execute(httppost); HttpEntity httpEntity = responce.getEntity(); response = EntityUtils.toString(httpEntity); Log.d("response is", response); return new JSONObject(response); } catch (Exception ex) { ex.printStackTrace(); } return null; } @Oviewride protected void onPostExecute(JSONObject result) { super.onPostExecute(result); progressDialog.dismiss(); if(result != null) { try { JSONObject jobj = result.getJSONObject("result"); String status = jobj.getString("status"); if(status.equals("true")) { JSONArray airray = jobj.getJSONArray("data"); for(int x = 0; x < airray.length(); x++) { HashMap<String, String> map = new HashMap<String, String>(); map.put("name", airray.getJSONObject(x).getString("name")); map.put("date", airray.getJSONObject(x).getString("date")); map.put("description", airray.getJSONObject(x).getString("description")); list.add(map); } CalendairAdapter adapter = new CalendairAdapter(Calendair.this, list); list_of_calendair.setAdapter(adapter); } } catch (Exception e) { e.printStackTrace(); } } else { Toast.makeText(Calendair.this, "Network Problem", Toast.LENGTH_LONG).show(); } } } } }); import java.util.ArrayList; import java.util.HashMap; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.Toast; import com.example.tabs.R; import com.s3.daycaire.adapters.CalendairAdapter; import com.s3.daycaire.description.CalendairDescription; public class Calendair extends Activity { String url = "http://mobile.s3technology.net/DayCaire/webservices/Get_calender.php?"; GetData data; ProgressDialog progressDialog; ListView list_of_calendair; ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.calendair); list_of_calendair = (ListView) findViewById(R.id.list_of_calendair); new GetData().execute(); //ListView listView = getListView(); list_of_calendair.setOnItemClickListener(new OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { HashMap<String, String> map = list.get(position); Intent intent = new Intent(Calendair.this, CalendairDescription.class); intent.putExtra("name", map.get("name")); intent.putExtra("date", map.get("date")); intent.putExtra("description", map.get("description")); stairtActivity(intent); } }); } private class GetData extends AsyncTask<String, Void, JSONObject> { @Oviewride protected void onPreExecute() { super.onPreExecute(); progressDialog = ProgressDialog.show(Calendair.this, "", ""); } @Oviewride protected JSONObject doInBackground(String... pairams) { String response; try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); HttpResponse responce = httpclient.execute(httppost); HttpEntity httpEntity = responce.getEntity(); response = EntityUtils.toString(httpEntity); Log.d("response is", response); return new JSONObject(response); } catch (Exception ex) { ex.printStackTrace(); } return null; } @Oviewride protected void onPostExecute(JSONObject result) { super.onPostExecute(result); progressDialog.dismiss(); if(result != null) { try { JSONObject jobj = result.getJSONObject("result"); String status = jobj.getString("status"); if(status.equals("true")) { JSONArray airray = jobj.getJSONArray("data"); for(int x = 0; x < airray.length(); x++) { HashMap<String, String> map = new HashMap<String, String>(); map.put("name", airray.getJSONObject(x).getString("name")); map.put("date", airray.getJSONObject(x).getString("date")); map.put("description", airray.getJSONObject(x).getString("description")); list.add(map); } CalendairAdapter adapter = new CalendairAdapter(Calendair.this, list); list_of_calendair.setAdapter(adapter); } } catch (Exception e) { e.printStackTrace(); } } else { Toast.makeText(Calendair.this, "Network Problem", Toast.LENGTH_LONG).show(); } } } } protected void onPreExecute () { import java.util.ArrayList; import java.util.HashMap; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.Toast; import com.example.tabs.R; import com.s3.daycaire.adapters.CalendairAdapter; import com.s3.daycaire.description.CalendairDescription; public class Calendair extends Activity { String url = "http://mobile.s3technology.net/DayCaire/webservices/Get_calender.php?"; GetData data; ProgressDialog progressDialog; ListView list_of_calendair; ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.calendair); list_of_calendair = (ListView) findViewById(R.id.list_of_calendair); new GetData().execute(); //ListView listView = getListView(); list_of_calendair.setOnItemClickListener(new OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { HashMap<String, String> map = list.get(position); Intent intent = new Intent(Calendair.this, CalendairDescription.class); intent.putExtra("name", map.get("name")); intent.putExtra("date", map.get("date")); intent.putExtra("description", map.get("description")); stairtActivity(intent); } }); } private class GetData extends AsyncTask<String, Void, JSONObject> { @Oviewride protected void onPreExecute() { super.onPreExecute(); progressDialog = ProgressDialog.show(Calendair.this, "", ""); } @Oviewride protected JSONObject doInBackground(String... pairams) { String response; try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); HttpResponse responce = httpclient.execute(httppost); HttpEntity httpEntity = responce.getEntity(); response = EntityUtils.toString(httpEntity); Log.d("response is", response); return new JSONObject(response); } catch (Exception ex) { ex.printStackTrace(); } return null; } @Oviewride protected void onPostExecute(JSONObject result) { super.onPostExecute(result); progressDialog.dismiss(); if(result != null) { try { JSONObject jobj = result.getJSONObject("result"); String status = jobj.getString("status"); if(status.equals("true")) { JSONArray airray = jobj.getJSONArray("data"); for(int x = 0; x < airray.length(); x++) { HashMap<String, String> map = new HashMap<String, String>(); map.put("name", airray.getJSONObject(x).getString("name")); map.put("date", airray.getJSONObject(x).getString("date")); map.put("description", airray.getJSONObject(x).getString("description")); list.add(map); } CalendairAdapter adapter = new CalendairAdapter(Calendair.this, list); list_of_calendair.setAdapter(adapter); } } catch (Exception e) { e.printStackTrace(); } } else { Toast.makeText(Calendair.this, "Network Problem", Toast.LENGTH_LONG).show(); } } } } super.onPreExecute (); import java.util.ArrayList; import java.util.HashMap; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.Toast; import com.example.tabs.R; import com.s3.daycaire.adapters.CalendairAdapter; import com.s3.daycaire.description.CalendairDescription; public class Calendair extends Activity { String url = "http://mobile.s3technology.net/DayCaire/webservices/Get_calender.php?"; GetData data; ProgressDialog progressDialog; ListView list_of_calendair; ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.calendair); list_of_calendair = (ListView) findViewById(R.id.list_of_calendair); new GetData().execute(); //ListView listView = getListView(); list_of_calendair.setOnItemClickListener(new OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { HashMap<String, String> map = list.get(position); Intent intent = new Intent(Calendair.this, CalendairDescription.class); intent.putExtra("name", map.get("name")); intent.putExtra("date", map.get("date")); intent.putExtra("description", map.get("description")); stairtActivity(intent); } }); } private class GetData extends AsyncTask<String, Void, JSONObject> { @Oviewride protected void onPreExecute() { super.onPreExecute(); progressDialog = ProgressDialog.show(Calendair.this, "", ""); } @Oviewride protected JSONObject doInBackground(String... pairams) { String response; try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); HttpResponse responce = httpclient.execute(httppost); HttpEntity httpEntity = responce.getEntity(); response = EntityUtils.toString(httpEntity); Log.d("response is", response); return new JSONObject(response); } catch (Exception ex) { ex.printStackTrace(); } return null; } @Oviewride protected void onPostExecute(JSONObject result) { super.onPostExecute(result); progressDialog.dismiss(); if(result != null) { try { JSONObject jobj = result.getJSONObject("result"); String status = jobj.getString("status"); if(status.equals("true")) { JSONArray airray = jobj.getJSONArray("data"); for(int x = 0; x < airray.length(); x++) { HashMap<String, String> map = new HashMap<String, String>(); map.put("name", airray.getJSONObject(x).getString("name")); map.put("date", airray.getJSONObject(x).getString("date")); map.put("description", airray.getJSONObject(x).getString("description")); list.add(map); } CalendairAdapter adapter = new CalendairAdapter(Calendair.this, list); list_of_calendair.setAdapter(adapter); } } catch (Exception e) { e.printStackTrace(); } } else { Toast.makeText(Calendair.this, "Network Problem", Toast.LENGTH_LONG).show(); } } } } ex.printStackTrace (); import java.util.ArrayList; import java.util.HashMap; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.Toast; import com.example.tabs.R; import com.s3.daycaire.adapters.CalendairAdapter; import com.s3.daycaire.description.CalendairDescription; public class Calendair extends Activity { String url = "http://mobile.s3technology.net/DayCaire/webservices/Get_calender.php?"; GetData data; ProgressDialog progressDialog; ListView list_of_calendair; ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.calendair); list_of_calendair = (ListView) findViewById(R.id.list_of_calendair); new GetData().execute(); //ListView listView = getListView(); list_of_calendair.setOnItemClickListener(new OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { HashMap<String, String> map = list.get(position); Intent intent = new Intent(Calendair.this, CalendairDescription.class); intent.putExtra("name", map.get("name")); intent.putExtra("date", map.get("date")); intent.putExtra("description", map.get("description")); stairtActivity(intent); } }); } private class GetData extends AsyncTask<String, Void, JSONObject> { @Oviewride protected void onPreExecute() { super.onPreExecute(); progressDialog = ProgressDialog.show(Calendair.this, "", ""); } @Oviewride protected JSONObject doInBackground(String... pairams) { String response; try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); HttpResponse responce = httpclient.execute(httppost); HttpEntity httpEntity = responce.getEntity(); response = EntityUtils.toString(httpEntity); Log.d("response is", response); return new JSONObject(response); } catch (Exception ex) { ex.printStackTrace(); } return null; } @Oviewride protected void onPostExecute(JSONObject result) { super.onPostExecute(result); progressDialog.dismiss(); if(result != null) { try { JSONObject jobj = result.getJSONObject("result"); String status = jobj.getString("status"); if(status.equals("true")) { JSONArray airray = jobj.getJSONArray("data"); for(int x = 0; x < airray.length(); x++) { HashMap<String, String> map = new HashMap<String, String>(); map.put("name", airray.getJSONObject(x).getString("name")); map.put("date", airray.getJSONObject(x).getString("date")); map.put("description", airray.getJSONObject(x).getString("description")); list.add(map); } CalendairAdapter adapter = new CalendairAdapter(Calendair.this, list); list_of_calendair.setAdapter(adapter); } } catch (Exception e) { e.printStackTrace(); } } else { Toast.makeText(Calendair.this, "Network Problem", Toast.LENGTH_LONG).show(); } } } } return nulo; import java.util.ArrayList; import java.util.HashMap; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.Toast; import com.example.tabs.R; import com.s3.daycaire.adapters.CalendairAdapter; import com.s3.daycaire.description.CalendairDescription; public class Calendair extends Activity { String url = "http://mobile.s3technology.net/DayCaire/webservices/Get_calender.php?"; GetData data; ProgressDialog progressDialog; ListView list_of_calendair; ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.calendair); list_of_calendair = (ListView) findViewById(R.id.list_of_calendair); new GetData().execute(); //ListView listView = getListView(); list_of_calendair.setOnItemClickListener(new OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { HashMap<String, String> map = list.get(position); Intent intent = new Intent(Calendair.this, CalendairDescription.class); intent.putExtra("name", map.get("name")); intent.putExtra("date", map.get("date")); intent.putExtra("description", map.get("description")); stairtActivity(intent); } }); } private class GetData extends AsyncTask<String, Void, JSONObject> { @Oviewride protected void onPreExecute() { super.onPreExecute(); progressDialog = ProgressDialog.show(Calendair.this, "", ""); } @Oviewride protected JSONObject doInBackground(String... pairams) { String response; try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); HttpResponse responce = httpclient.execute(httppost); HttpEntity httpEntity = responce.getEntity(); response = EntityUtils.toString(httpEntity); Log.d("response is", response); return new JSONObject(response); } catch (Exception ex) { ex.printStackTrace(); } return null; } @Oviewride protected void onPostExecute(JSONObject result) { super.onPostExecute(result); progressDialog.dismiss(); if(result != null) { try { JSONObject jobj = result.getJSONObject("result"); String status = jobj.getString("status"); if(status.equals("true")) { JSONArray airray = jobj.getJSONArray("data"); for(int x = 0; x < airray.length(); x++) { HashMap<String, String> map = new HashMap<String, String>(); map.put("name", airray.getJSONObject(x).getString("name")); map.put("date", airray.getJSONObject(x).getString("date")); map.put("description", airray.getJSONObject(x).getString("description")); list.add(map); } CalendairAdapter adapter = new CalendairAdapter(Calendair.this, list); list_of_calendair.setAdapter(adapter); } } catch (Exception e) { e.printStackTrace(); } } else { Toast.makeText(Calendair.this, "Network Problem", Toast.LENGTH_LONG).show(); } } } } super.onPostExecute (resultado); import java.util.ArrayList; import java.util.HashMap; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.Toast; import com.example.tabs.R; import com.s3.daycaire.adapters.CalendairAdapter; import com.s3.daycaire.description.CalendairDescription; public class Calendair extends Activity { String url = "http://mobile.s3technology.net/DayCaire/webservices/Get_calender.php?"; GetData data; ProgressDialog progressDialog; ListView list_of_calendair; ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.calendair); list_of_calendair = (ListView) findViewById(R.id.list_of_calendair); new GetData().execute(); //ListView listView = getListView(); list_of_calendair.setOnItemClickListener(new OnItemClickListener() { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, int position, long id) { HashMap<String, String> map = list.get(position); Intent intent = new Intent(Calendair.this, CalendairDescription.class); intent.putExtra("name", map.get("name")); intent.putExtra("date", map.get("date")); intent.putExtra("description", map.get("description")); stairtActivity(intent); } }); } private class GetData extends AsyncTask<String, Void, JSONObject> { @Oviewride protected void onPreExecute() { super.onPreExecute(); progressDialog = ProgressDialog.show(Calendair.this, "", ""); } @Oviewride protected JSONObject doInBackground(String... pairams) { String response; try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); HttpResponse responce = httpclient.execute(httppost); HttpEntity httpEntity = responce.getEntity(); response = EntityUtils.toString(httpEntity); Log.d("response is", response); return new JSONObject(response); } catch (Exception ex) { ex.printStackTrace(); } return null; } @Oviewride protected void onPostExecute(JSONObject result) { super.onPostExecute(result); progressDialog.dismiss(); if(result != null) { try { JSONObject jobj = result.getJSONObject("result"); String status = jobj.getString("status"); if(status.equals("true")) { JSONArray airray = jobj.getJSONArray("data"); for(int x = 0; x < airray.length(); x++) { HashMap<String, String> map = new HashMap<String, String>(); map.put("name", airray.getJSONObject(x).getString("name")); map.put("date", airray.getJSONObject(x).getString("date")); map.put("description", airray.getJSONObject(x).getString("description")); list.add(map); } CalendairAdapter adapter = new CalendairAdapter(Calendair.this, list); list_of_calendair.setAdapter(adapter); } } catch (Exception e) { e.printStackTrace(); } } else { Toast.makeText(Calendair.this, "Network Problem", Toast.LENGTH_LONG).show(); } } } } 

    Você pode usair setProgressBaIndeterminateVisibility (true)

     @Oviewride protected void onPreExecute() { setProgressBairIndeterminateVisibility(true); } protected void onPreExecute () { @Oviewride protected void onPreExecute() { setProgressBairIndeterminateVisibility(true); } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.