VIEW没有连接到窗口管理 [英] VIEW is not attached to window manager

查看:159
本文介绍了VIEW没有连接到窗口管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发中,有四个tabs..in各做独立operations.in最后一个选项卡时操作finished.the机应用被刷新的应用程序。

i am developing an app in which there are four tabs..in each doing seperate operations.in the final tab when the operation is finished.the appliction is refreshed.

问题是,当应用刷新窗口泄漏误差obtained.view不附着于窗口manager.the误差示于行

the problem is when app refreshed window leakage error is obtained.view not attached to window manager.the error is shown in the line

 @Override
            protected void onPostExecute(Void result) {
                super.onPostExecute(result);
                if (pDialog.isShowing())
                    pDialog.dismiss();
                populateSpinner();
            }

正好在pDialog.dismiss();

exactly at pDialog.dismiss();

活动的主要部件如下所示

the main components of the activity is shown below

public class DayStartActivity extends Activity {
    ProgressDialog pDialog;
@Override
    protected void onCreate(Bundle savedInstanceState) {
    new Getdata().execute();

    //  new GetRouteoptmdata().execute();
    }
private class Getdata extends AsyncTask<Void, Void, Void> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(DayStartActivity.this);
            pDialog.setMessage("ON PROCESS..PLEASE WAIT..");
            pDialog.setCancelable(true);
            pDialog.show();

        }

        @Override
        protected Void doInBackground(Void... arg0) {
            ServiceHandler jsonParser = new ServiceHandler();
            String json = jsonParser.makeServiceCall(URL_DAYSTARTDATA,
                    ServiceHandler.POST);


            if (json != null) {
                try {
                    if(json.contains("<!--"))

                        json=json.substring(0, json.indexOf("<!--"));
                    Log.e("Response according to Gettabledata:: ", " " + json);
                    // JSONObject jsonObj = new JSONObject(json);
                    // if (jsonObj != null) {
                    JSONArray daystartdata = new JSONArray(json);
                    // .getJSONArray("categories");

                    for (int i = 0; i < daystartdata.length(); i++) {
                        JSONObject jsonChildNode = daystartdata
                                .getJSONObject(i);

                        DaystartSetGet daystart = new DaystartSetGet(
                                jsonChildNode.getString("altroutecode"),
                                jsonChildNode.getString("route"),
                                jsonChildNode.getString("salesrep"),
                                jsonChildNode.getString("name"),
                                jsonChildNode.getString("date"),
                                jsonChildNode.getString("time"),
                                jsonChildNode.getString("deleverydate"),
                                jsonChildNode.getString("week"),
                                jsonChildNode.getString("day"),
                                jsonChildNode.getString("vehiclenumber"));

                        routecodelist.add(daystart);

                    }
                    // }

                } catch (JSONException e) {
                    e.printStackTrace();
                }

            } else {
                Log.e("JSON Data", "Didn't receive any data from server!");
            }



            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            if (pDialog.isShowing())
                pDialog.dismiss();
        }

    }

当应用程序正在运行,第一次是没有问题的。当标签被刷新时出现问题。

when the app is running for the first time there is no problem. the problem occurs when the tabs are refreshed.

请帮忙me.Thanks提前

please help me.Thanks in advance

推荐答案

是活动仍然在前台,你不打开任何新的活动?

is the activity still on the foreground, and you don't open any new activity?

也,你有没有考虑使用标签的容器上的ViewSwitcher,而不是对话?谷歌建议避免对话框(尤其是ProgressDialog)尽可能: http://developer.android。 COM /引导/主题/ UI / dialogs.html

also, have you considered using a ViewSwitcher on the container of the tabs, instead of a dialog ? google suggests avoiding dialogs (especially ProgressDialog ) whenever possible : http://developer.android.com/guide/topics/ui/dialogs.html

如果你希望仍然使用ProgressDialog,认为所有可能的状态,该对话框应予以驳回的:活性被破坏,AsyncTask的被取消(应当活动被销毁至少应该发生,当用户取消对话框,根据您的应用程序的逻辑)。

if you wish to still use a ProgressDialog, think of all the possible states that the dialog should be dismissed : activity being destroyed, asyncTask being cancelled (which should should at least happen when the activity is being destroyed and when the user cancels the dialog, depending on the logic of your app).

这篇关于VIEW没有连接到窗口管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆