自定义警报对话框不显示Asynctask的Post Execute中的JSON数据

时间:2017-11-04 01:55:17

标签: java android json android-asynctask alertdialog

我在异步任务的post执行方法中显示自定义警报对话框时遇到了一个奇怪的问题。当程序运行时,我的预执行中的进度对话框首先在后执行中被解除,然后我显示我的自定义警报对话框,该对话框显示已解析的JSON数据。但在取消进度对话框后,自定义警报对话框根本不显示。

任何人都可以帮助解决发生这种情况的可能原因。这是我的post exec方法的代码。

        @Override
        protected void onPostExecute(String result)
        {
            loginDialog.dismiss();
            jsonstring = result;

            try
            {
                jsonObject = new JSONObject(jsonstring);
                jsonArray = jsonObject.getJSONArray("server_response");
                JSONObject JO = jsonArray.getJSONObject(0);

                fname = JO.getString("firstname");
                lname = JO.getString("lastname");
                possessionqty = JO.getString("possessionQty");
                email = JO.getString("email");
                status = JO.getString("status");

                mBuilder = new AlertDialog.Builder(activity);
                mView = getLayoutInflater().inflate(R.layout.studentinfo_alertdialog, null);

                studentIDheader = (TextView) mView.findViewById(R.id.textView3);
                studentfullname = (EditText) mView.findViewById(R.id.editText);
                studentpossessionqty = (EditText) mView.findViewById(R.id.editText2);
                studentemail = (EditText) mView.findViewById(R.id.editText3);
                studentstatus = (EditText) mView.findViewById(R.id.editText4);

                studentIDheader.setText(validatedID);
                studentfullname.setText("Full Name: " + fname + " " + lname);
                studentpossessionqty.setText("Possession Qty: " + possessionqty);
                studentemail.setText("Email: " + email);
                studentstatus.setText("Status: " + status);

                mBuilder.setCancelable(false);
                mBuilder.setView(mView);

                dialog = mBuilder.create();
                dialog.show();
            }
            catch (JSONException e)
            {
                e.printStackTrace();
            }
        }

0 个答案:

没有答案