【问题标题】:Why my progress dialog is not spinning while new intent start()?为什么我的进度对话框在新意图开始()时没有旋转?
【发布时间】:2012-07-04 10:03:43
【问题描述】:

我尝试打开第二个活动,这需要一些时间从主要活动首先从互联网加载数据,在此期间,我的屏幕将全黑,所以我决定使用进度对话框显示“嘿,我是还活着,别关我!” 一切都很顺利,但唯一的问题是微调器没有旋转。这是我的代码: 点击按钮后:new YourAsyncTask().execute();

public class YourAsyncTask extends AsyncTask<Void, Void, Void> {

    private ProgressDialog myDialog;

    @Override
    protected void onPreExecute() {
        //show your dialog here
        myDialog = ProgressDialog.show(ScrollingTab.this, "loading..", "please wait..", true, true);  
        myDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 
    }

    @Override
    protected Void doInBackground(Void... params) {        
        //update your DB - it will run in a different thread

        startActivity(new Intent("com.android.ricky.RESULT_DETAIL"));
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        //hide your dialog here
        myDialog.dismiss();
    }
}

我已尝试删除“ startActivity(new Intent("com.android.ricky.RESULT_DETAIL"));”和“myDialog.dismiss();”同时,然后微调器正在旋转>

【问题讨论】:

    标签: android spinner progressdialog


    【解决方案1】:

    你的概念有点混乱和错误,

    您必须在单击按钮时启动 2nd Activity,然后您的 2nd Activity 的 onCreate() 执行 YourAsyncTask()。并从互联网上下载doInBackground()AsyncTask 中的第二个活动的数据。完成下载后,为onPostExecute()AsyncTaskdismiss()ProgressDialog 中的第二个Activity 准备UI。

    【讨论】:

    • 非常感谢,你是对的,我的概念错了^^
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-24
    相关资源
    最近更新 更多