自定义对话框崩溃?

时间:2011-11-21 12:26:19

标签: android android-dialog

我在布局中有一个图像按钮。我想将其用作自定义对话框的启动器。但是当我点击它时程序崩溃了。我正在使用的代码如下:

ImageButton bt = (ImageButton) findViewById(R.id.print_button);

    bt.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Dialog dialog = new Dialog(Details.this);
            dialog.setContentView(R.layout.sharepopup);
            dialog.setTitle("");
            dialog.setCancelable(true);
            dialog.show();
          }
    }
那是错的吗?提前谢谢。

1 个答案:

答案 0 :(得分:0)

LayoutInflater newProject = LayoutInflater.from(Details.this);
View projectView =newProject.inflate(R.layout.sharepopup, null);

Dialog dialog= new Dialog(Details.this);
dialog.setContentView(projectView);
....

试试这个......

相关问题