调用时,ProgressDialog不会在asyncTask中显示

时间:2014-08-29 15:48:56

标签: java android android-asynctask progressdialog

我通过按钮调用asyncTask。它工作,它完成所有操作,但它没有显示我设置的ProgressDialog。

`私有类CaricaValori扩展了AsyncTask {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        dialog = new ProgressDialog(MainActivity.this);
        dialog.setTitle("Tratta");
        dialog.setMessage("Carico tratta...");
        dialog.setIndeterminate(false);
        dialog.show();

    }

    @Override
    protected Void doInBackground(Void... arg0) {
        // TODO Auto-generated method stub
        runOnUiThread(new Runnable() {

                @Override
                public void run()
                {
                    // TODO: Implement this method
                    String start = startEdit.getText().toString();
                    String end = endEdit.getText().toString();

                    partenza = start.replace(" ", "+");
                    arrivo = end.replace(" ","+");
                    String Address = ReadAddressFromWebService(partenza,arrivo);
                    results.setText(Address);

                    //Toast.makeText(MainActivity.this,Address, Toast.LENGTH_LONG).show();
                }



        });

        return null;
    }


    @Override
    protected void onPostExecute(Void result) {
        super.onPostExecute(result);
            dialog.dismiss();
        }       

    }`

看起来没错,但没有表现出来。

0 个答案:

没有答案