(4.3.1.7)【项目一】子Fragment之对话框

来源:互联网 发布:centos 6.5搭建lnmp 编辑:程序博客网 时间:2024/05/18 21:06
public static void ShowCodingDialog(Context context) {        // TODO Auto-generated method stub        ImageView imageView = new ImageView(context);        imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));        imageView.setImageResource(R.drawable.yunshi_fail_nolgin_img);        final Dialog dialog = new Dialog(context);         dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);        dialog.setContentView(R.layout.yunshi_dialog);         dialog.setCanceledOnTouchOutside(false);        TextView title=(TextView) dialog.findViewById(R.id.yunshi_dialog_title);        LinearLayout content=(LinearLayout) dialog.findViewById(R.id.yunshi_dialog_content_ll_out);        Button ok=(Button) dialog.findViewById(R.id.yunshi_dialog_id_ok);        Button cancel=(Button) dialog.findViewById(R.id.yunshi_dialog_id_cancel);        title.setText(context.getResources().getString(R.string.codeing));        content.removeAllViews();        content.addView(imageView);        ok.setVisibility(View.GONE);        cancel.setVisibility(View.GONE);        dialog.show();         final Timer t = new Timer();        t.schedule(new TimerTask() {                                public void run() {                                    dialog.dismiss(); // when the task active then close the dialog                                    t.cancel(); // also just top the timer thread, otherwise, you may receive a crash report                                }                            }, 3000); // after 2 second (or 2000 miliseconds), the task will be active.    }
0 0