Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 自定义AlertDialog中的动画_Android - Fatal编程技术网

Android 自定义AlertDialog中的动画

Android 自定义AlertDialog中的动画,android,Android,我使用以下代码在自定义AlertDialog内设置加载循环的动画: public static void create_custom_progress_dialog(Activity activity, String message){ Context mContext = activity; AlertDialog.Builder builder; AlertDialog custom_progress_dialo

我使用以下代码在自定义AlertDialog内设置加载循环的动画:

    public static void create_custom_progress_dialog(Activity activity, String message){
            Context mContext = activity;
            AlertDialog.Builder builder;
            AlertDialog custom_progress_dialog;         

            LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(R.layout.myprogressbar, null);

            TextView tv_message = (TextView) layout.findViewById(R.id.message);
            tv_message.setText("" + message);
            ImageView loading_circle = (ImageView)layout.findViewById(R.id.loading_circle);
            loading_circle.setBackgroundResource(R.anim.progress_anim);

            /////////////My ANIMATION/////////////////
            final AnimationDrawable frameAnimation = (AnimationDrawable)loading_circle.getBackground();
            frameAnimation.setCallback(loading_circle);
            frameAnimation.setVisible(true, true);
            loading_circle.post(new Runnable(){

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    frameAnimation.start();
                }

            });

            builder = new AlertDialog.Builder(mContext);
            builder.setView(layout);
            custom_progress_dialog = builder.create();
            custom_progress_dialog.show();
        }

图像正在显示,但未设置动画。我做错了什么?

你从哪里开始动画?注意到行
加载\u circle.post..
。我假设这将在我调用该方法时开始。您可以尝试在其他地方启动动画吗?制作一个按钮来启动它或类似的东西,或者在show()之后启动它;我不知道这个问题的答案。但是如果您查看这个线程,它会说在视图完全连接到窗口之前,不会调用post/removecallback。因此,我建议尝试延迟发布,或者可能是在使用GloaballayoutListNer绘制之后发布。我尝试将
加载\u circle.post..
放在
自定义\u progress\u对话框之后。显示
但它仍然没有动画。你从哪里开始动画?注意到行
加载\u circle.post..
。我假设这将在我调用该方法时开始。您可以尝试在其他地方启动动画吗?制作一个按钮来启动它或类似的东西,或者在show()之后启动它;我不知道这个问题的答案。但是如果您查看这个线程,它会说在视图完全连接到窗口之前,不会调用post/removecallback。因此,我建议尝试延迟发布,或者可能是在使用GloaballayoutListNer绘制之后发布。我尝试在自定义进度对话框之后放置
加载圆圈。发布..
。显示
但它仍然没有动画。