Android ProgressDialog阴影出现
Android ProgressDialog shadow appears
在我的 android 应用程序中,在循环中连续调用 API,然后进度对话框会产生类似阴影的外观。我认为问题在于多个对话框 运行..帮助我避免这种阴影。代码如下:
for(int i = indexOfSelectedId + 1 ; i < photoall_id.size(); i++)
{
all_postid.add(photoall_id.get(i));
url = URLS.BASEURL + "mobile_api.php?action=post&post_id=" +posoall_id.get(i)+user_id="+userid;
new GetImage().execute(url);
}
private class GetImage extends AsyncTask<String, Void, ArrayList<String>> {
String json = null;
ProgressDialog dialog;
@Override
protected void onPreExecute() {
all_data=new ArrayList<>();
dialog = new ProgressDialog(FullScreenActivity.this);
dialog.setMessage("Loading Image...");
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(false);
dialog.show();
super.onPreExecute();
}
@Override
protected void onPostExecute(ArrayList<String> aVoid) {
dialog.dismiss();
all_url.add(aVoid.get(0));
}
@Override
protected ArrayList<String> doInBackground(String... params) {
JSONReader reader = new JSONReader();
json = reader.getJsonGET(params[0]);
if (json != null) {
try {
JSONObject object = new JSONObject(json);
if (object.getJSONArray("posts").getJSONObject(0).getInt("count") != 0) {
photo_url = object.getJSONArray("posts").getJSONObject(0).getString("photo_url");
}
}
提前建议solution.Thanks
为了避免显示多个对话框:
public void showProgress(String msg)
{
if(dialog == null){
dialog = new ProgressDialog(this);
dialog.setTitle(null);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
}
if(dialog.isShowing())
{
dialog.dismiss();
}
dialog.setMessage(msg);
dialog.show();
}
public void dismissProgress()
{
if(dialog != null && dialog.isShowing())
dialog.dismiss();
}
在我的 android 应用程序中,在循环中连续调用 API,然后进度对话框会产生类似阴影的外观。我认为问题在于多个对话框 运行..帮助我避免这种阴影。代码如下:
for(int i = indexOfSelectedId + 1 ; i < photoall_id.size(); i++)
{
all_postid.add(photoall_id.get(i));
url = URLS.BASEURL + "mobile_api.php?action=post&post_id=" +posoall_id.get(i)+user_id="+userid;
new GetImage().execute(url);
}
private class GetImage extends AsyncTask<String, Void, ArrayList<String>> {
String json = null;
ProgressDialog dialog;
@Override
protected void onPreExecute() {
all_data=new ArrayList<>();
dialog = new ProgressDialog(FullScreenActivity.this);
dialog.setMessage("Loading Image...");
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(false);
dialog.show();
super.onPreExecute();
}
@Override
protected void onPostExecute(ArrayList<String> aVoid) {
dialog.dismiss();
all_url.add(aVoid.get(0));
}
@Override
protected ArrayList<String> doInBackground(String... params) {
JSONReader reader = new JSONReader();
json = reader.getJsonGET(params[0]);
if (json != null) {
try {
JSONObject object = new JSONObject(json);
if (object.getJSONArray("posts").getJSONObject(0).getInt("count") != 0) {
photo_url = object.getJSONArray("posts").getJSONObject(0).getString("photo_url");
}
}
提前建议solution.Thanks
为了避免显示多个对话框:
public void showProgress(String msg)
{
if(dialog == null){
dialog = new ProgressDialog(this);
dialog.setTitle(null);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
}
if(dialog.isShowing())
{
dialog.dismiss();
}
dialog.setMessage(msg);
dialog.show();
}
public void dismissProgress()
{
if(dialog != null && dialog.isShowing())
dialog.dismiss();
}