【问题标题】:android loader not showing in dialog boxandroid加载器未显示在对话框中
【发布时间】:2015-08-27 13:36:46
【问题描述】:

我正在使用专用库处理图像。这发生在出现警报对话框之后,然后当单击positive/ok 时,图像被处理。这个处理可能很长,所以我尝试显示一些加载程序。所以我尝试了这个:

setPositiveButton(getResources().getString(...), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        Activity activity = getActivity();
                        ProgressDialog pd = ProgressDialog.show(activity, "Process", "Searching...", true, false);
                        ImageView image = (ImageView) activity.findViewById(...);

                        try {
                            process_image
                        } catch (Exception e) {
                            //some thing
                        }
                        // some code
                        pd.dismiss();

但加载程序没有显示。我也试过activity.findViewById(R.id.loadingPanel).setVisibility(View.VISIBLE); ,但也没有用。有人有想法吗?

【问题讨论】:

    标签: java android android-alertdialog universal-image-loader


    【解决方案1】:

    试试这个:

    class proceesImageTask extends AsyncTask<Void,Void,Void>
    {
     ProgressDialog dialog;
                @Override
                protected void onPreExecute() {
                    super.onPreExecute();
    
                    dialog = ProgressDialog.show(context, "","Please wait...", true);
                    dialog.show();
    
                }
    @Override
                protected Void doInBackground(String... str) {
    //your process
    }
    
    @Override
                protected void onPostExecute(Void result) {
    dialog.dismiss();   
    }
    }
    

    new proceesImageTask().execute();

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-08
      • 2021-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多