自定义系统dialog

AlertDialog dialog =     new AlertDialog.Builder(getActivity())
                        .setTitle("删除")
                        .setMessage("确定要删除吗?")
                        .setPositiveButton("是", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {



                                //移除上传任务
                                UploadManager.getInstance().getThreadPool().remove(uploadFinishedInfos.get(position).getTask().getRunnable());
                                //发送上传任务状态更新
                                EventBus.getDefault().post(BaseEvent.UploadEvent.UPLOADING_MESSAGE);
//                                initData(null);
                            }
                        })
                        .setNegativeButton("否", null)
                        .create();
                dialog.show();
                dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(Color.parseColor("#292929"));
                dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextSize(14);
                dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(Color.parseColor("#2785f1"));
                dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(14);

                try {
                    Field mAlert = AlertDialog.class.getDeclaredField("mAlert");
                    mAlert.setAccessible(true);
                    Object mAlertController = mAlert.get(dialog);
                    Field mtitile2 = mAlertController.getClass().getDeclaredField("mTitleView");
                    mtitile2.setAccessible(true);
                    TextView mTitleView = (TextView)mtitile2.get(mAlertController);
                    mTitleView.setText("删除");
                    mTitleView.setTextSize(15);
                    mTitleView.setTextColor(Color.parseColor("#292929"));
                    Field mMessage = mAlertController.getClass().getDeclaredField("mMessageView");
                    mMessage.setAccessible(true);
                    TextView mMessageView = (TextView) mMessage.get(mAlertController);
                    mMessageView.setTextColor(Color.parseColor("#626262"));
                    mMessageView.setTextSize(12);
                    mMessageView.setText("确认删除吗?");
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                } catch (NoSuchFieldException e) {
                    e.printStackTrace();
                }

你可能感兴趣的:(android开发)