对话失去了焦点?整个屏幕“灰色”

时间:2013-09-22 23:26:31

标签: android dialog focus

因此系统会提示用户输入文件名,文件将保存到外部存储器中。一旦完成,我将另一种方法称为保存到Dropbox。这会创建另一个对话框一个简单的“是/否”,用户可以接受或拒绝保存到Dropbox。

当文件保存到外部存储器时,Dropbox对话框会显示,但整个屏幕显示为灰色,就像失去焦点一样。点击屏幕使其恢复正常,所有功能都可以,但很烦人。代码和截图如下。

   private void saveToSD(){

    //Build dialog etc

    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

    // Save file to phone and then...

            saveToDropbox();

        }
    });

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
        });

    builder.show();
}

saveToDropbox();方法......

private void saveToDropbox(){
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    if (mDbxAcctMgr.hasLinkedAccount()){

        new AlertDialog.Builder(this)
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setTitle("Upload to Dropbox")
                .setMessage("Do you want to upload the file to Dropbox?")
                .setPositiveButton("Yes", new DialogInterface.OnClickListener()
                {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        Toast.makeText(getApplicationContext(), "This is when we would save to Dbx", Toast.LENGTH_LONG).show();
                    }

                })
                .setNegativeButton("No", null)
                .show();

        builder.show();
    }else{
        Toast.makeText(getApplicationContext(), "Not linked to Dropbox", Toast.LENGTH_LONG).show();
    }
}

enter image description here

1 个答案:

答案 0 :(得分:2)

在为“真实”对话框调用show后,您正在为dialog调用'空'show。尝试删除行.-

AlertDialog.Builder builder = new AlertDialog.Builder(this);

builder.show();