2

我正在使用以下代码为自定义 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();
        }

图像正在显示,但没有动画。我究竟做错了什么?

4

0 回答 0