alertdialog——setview 的 自定义view

我在做一个alertdialog时出错,关于自定义view,
下面是正确的调用代码,onCreateDialog方法中:
[align=left]   LayoutInflater inflater2 =LayoutInflater.from(this);
//dialog_set_merge是一个RadioGroup ,含有两个选项
View merge_view = inflater2.inflate(R.layout.dialog_set_merge,null);

RadioGroup radioGroup_merge =[b] (RadioGroup) merge_view[/b].findViewById(R.id.radioGroup_merge);

final RadioButton inner_to_sd = (RadioButton) merge_view.findViewById(R.id.radion_merge1);

check_merge = true;

inner_to_sd.setClickable(true);

inner_to_sd.setChecked(true);

radioGroup_merge.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {

if (checkedId == inner_to_sd.getId())

check_merge = true;

else

check_merge = false;

 }
 });

AlertDialog.Builder dialog_merge = new AlertDialog.Builder(YyBackUpSetting.this);

dialog_merge.setOnKeyListener(new DialogInterface.OnKeyListener() {
 @Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) {
                                    return true;
                                }
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {

                                }
                                return false;
                            }
                        })

.setTitle(R.string.set_merge)

 .setView(merge_view)

 .setPositiveButton(R.string.dialog_ok,new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
showWaitingDialog();

new Thread(new Runnable() {
  @Override
  public void run() {
Looper.prepare();
                                                Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
 if (Environment.getExternalStorageDirectorySd() != null) {
  if (Environment.getExternalStorageStateSd()                                                   .equals(Environment.MEDIA_MOUNTED)) {
 fileHelper = new FileHelper(  
                                                             YyBackUpSetting.this);

String path = Environment                                                               .getExternalStorageDirectory()                                                           .toString()                                                              + "/yybackup/";

File srcFile = new File(path);

  String paString = Environment                                                               .getExternalStorageDirectorySd()                                                               .toString()                                                              + "/yybackup/";
  File destFile = new File(paString);

 if (check_merge) {
// 从手机到外置存储卡
try {
                                                                fileHelper.copyDirFilesTo(srcFile,
                                                                        destFile);
  } catch (IOException e) {
     }
                                                            fileHelper.delDir(srcFile);
 } else {
   // 外置存储卡到手机
 try {
                                                                fileHelper.copyDirFilesTo(destFile,
                                                                        srcFile);
                                                            } catch (IOException e) {
                                                                // TODO
                                                                // Auto-generated
                                                                // catch block
                                                                e.printStackTrace();
                                                            }
                                                            fileHelper.delDir(destFile);

                                                        }
                                                        cancelDialog();
                                                        YyBackUpGF.showToast(YyBackUpSetting.this,
                                                                R.string.set_merge_sucess);
                                                    } else {
                                                        removeDialog(DIALOG_SET_MERGE);
                                                        cancelDialog();
                                                        YyBackUpGF.showToast(YyBackUpSetting.this,
                                                                R.string.set_merge_not_legal);
                                                    }
                                                } else {
                                                    cancelDialog();
                                                    YyBackUpGF.showToast(YyBackUpSetting.this,
                                                            R.string.set_merge_not_find_sd);
                                                }
                                                Looper.loop();
                                            }

                                        }).start();
                                    }
                                })
                        .setNegativeButton(R.string.dialog_cancel,
                                new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        removeDialog(DIALOG_SET_MERGE);
                                    }
                                });
                return dialog_merge.create();[/align]

            

你可能感兴趣的:(thread)